/* "Hội thoại mỗi ngày" (web/conversations.js), adopted by the feature's shadow root: nothing here reaches the app. */

:host {
  display: block;
  container: conv / inline-size;
  color-scheme: light;
  /* The app's tokens (app.css --md-*), inherited through the shadow boundary; fallbacks for safety. */
  --bg: var(--md-background, #f3f6f5);
  --surface: var(--md-surface, #ffffff);
  --surface-2: var(--md-surface-container, #eef3f2);
  --ink: var(--md-on-surface, #0e2420);
  --muted: var(--md-on-surface-variant, #4b5f5b);
  --faint: var(--md-outline, #7d908c);
  --line: var(--md-outline-variant, #dce5e3);
  --primary: var(--md-primary, #00796b);
  --primary-hover: #00695c;
  --on-primary: #ffffff;
  --primary-soft: var(--md-primary-container, #ddf0ec);
  --on-primary-soft: var(--md-on-primary-container, #00413a);
  --success: var(--md-success, #2e7d32);
  --streak: var(--md-streak, #f29d2e);
  --a: #00796b;
  --b: #b4531a;
  --rec: #d93025;
  --amber: #f6c965;
  --bubble: #fffdf7;
  --bubble-ink: #15201e;
  --bubble-line: #1f2e2b;
  --scrim: rgb(8 20 18 / 0.48);
  --shadow: var(--md-card-shadow, 0 1px 2px rgb(14 36 32 / 0.06), 0 4px 14px rgb(14 36 32 / 0.04));
  --shadow-hover: var(--md-card-shadow-hover, 0 2px 4px rgb(14 36 32 / 0.06), 0 12px 28px rgb(14 36 32 / 0.08));
  --shadow-lg: 0 2px 6px rgb(14 36 32 / 0.08), 0 24px 48px rgb(14 36 32 / 0.16);
  --font: Mali, var(--font-app, ui-rounded), system-ui, -apple-system, 'Segoe UI', sans-serif;
  --deck: 184px;
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
.player, .library, .saved, .snack { color: var(--ink); font: 500 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { cursor: default; opacity: 0.4; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 12px; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icons { position: absolute; width: 0; height: 0; overflow: hidden; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Library (mobile ConversationListScreen) ---------- */
.library { max-width: 1080px; margin: 0 auto; padding: 0 0 32px; display: grid; gap: 16px; }
.lib-section { display: grid; gap: 12px; }
.lib-status { margin: 0; color: var(--muted); font-size: 14.5px; }
.lib-status:empty { display: none; }
.section-label { margin: 8px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); }

/* today: the whole wide drawing (3:2, uncropped) under a soft shade */
.today-card { position: relative; display: block; width: 100%; max-width: 760px; border-radius: var(--md-radius-xl, 24px); overflow: hidden; aspect-ratio: 3 / 2; background: var(--surface-2); box-shadow: var(--shadow); color: #fff; text-decoration: none; isolation: isolate; }
.today-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; transition: transform 0.6s cubic-bezier(.2,.7,.2,1); }
.today-card::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(180deg, transparent 5%, rgb(6 22 19 / 0.4) 35%, rgb(6 22 19 / 0.7) 60%, rgb(6 22 19 / 0.9)); }
/* On a phone the text reaches a third of the way up, over the bright part of the scene. */
.today-body { text-shadow: 0 1px 6px rgb(6 22 19 / 0.45); }
.today-body { position: absolute; left: 0; right: 0; bottom: 0; padding: 20px 22px; display: grid; gap: 6px; }
.today-meta { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; color: rgb(255 255 255 / 0.92); }
.today-body h3 { margin: 0; font-size: clamp(24px, 4.4vw, 34px); line-height: 1.12; font-weight: 600; }
.today-sum { margin: 0; max-width: 52ch; font-size: 15px; color: rgb(255 255 255 / 0.9); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.today-go { text-shadow: none; justify-self: start; margin-top: 6px; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 20px 0 16px; border-radius: 999px; background: #fff; color: var(--on-primary-soft); font-weight: 600; }
.today-go svg { width: 18px; height: 18px; color: var(--primary); }

/* "Đang luyện dở": a part started and not finished */
.continue-card { display: flex; align-items: center; gap: 12px; max-width: 760px; padding: 12px; border-radius: var(--md-radius-xl, 24px); background: var(--primary-soft); color: var(--on-primary-soft); text-decoration: none; }
.continue-card img { width: 72px; height: 48px; border-radius: var(--md-radius-s, 8px); object-fit: cover; flex: none; }
.cc-text { flex: 1; min-width: 0; display: grid; }
.cc-text small { font-size: 12.5px; opacity: 0.8; }
.cc-text strong { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-text span { font-size: 13px; }

/* level filter (FilterChip) */
.levels { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-filter { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--faint); color: var(--ink); font-size: 14px; font-weight: 600; }
.chip-filter svg { width: 16px; height: 16px; stroke-width: 2.6; margin-left: -4px; }
.chip-filter[aria-pressed="true"] { background: var(--primary-soft); border-color: transparent; color: var(--on-primary-soft); }

/* rows: one card with dividers on phones, a grid of cards on wider screens */
.lesson-list { list-style: none; margin: 0; padding: 0; display: grid; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); overflow: hidden; }
.lesson-list li + li { border-top: 1px solid var(--line); }
.lesson-card { display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: center; padding: 12px; color: inherit; text-decoration: none; transition: background 0.15s; }
.lesson-card img { width: 112px; height: 75px; border-radius: 12px; object-fit: cover; background: var(--surface-2); }
.lc-text { min-width: 0; }
.lesson-card h3 { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 600; }
.lesson-card .sub { margin: 2px 0 6px; color: var(--muted); font-size: 13.5px; }
.badges { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; }
.badge.done { background: var(--primary-soft); color: var(--on-primary-soft); }
.badge svg { width: 13px; height: 13px; stroke-width: 2.6; }
.level { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--on-primary-soft); font-size: 12.5px; font-weight: 600; line-height: 1.5; }
.level.on-dark { background: #fff; color: #00413a; }
/* wide screens: the drawing beside its words, not a full-width poster */
@container conv (min-width: 860px) {
  .today-card { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); max-width: none; aspect-ratio: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
  .today-card::after { display: none; }
  .today-card img { position: static; z-index: auto; aspect-ratio: 3 / 2; height: auto; }
  .today-body { position: static; align-content: center; gap: 10px; padding: 28px 32px; text-shadow: none; }
  .today-meta { color: var(--muted); }
  .today-meta .level.on-dark { background: var(--primary-soft); color: var(--on-primary-soft); }
  .today-body h3 { font-size: 32px; }
  .today-sum { color: var(--muted); -webkit-line-clamp: 3; }
  .today-go { margin-top: 10px; background: var(--primary); color: var(--on-primary); min-height: 50px; padding: 0 24px 0 18px; }
  .today-go svg { color: currentColor; }
  .continue-card { max-width: none; }
}
@container conv (min-width: 700px) {
  .lesson-list { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; border: 0; border-radius: 0; background: none; overflow: visible; }
  .lesson-list li + li { border-top: 0; }
  .lesson-card { grid-template-columns: 1fr; gap: 0; padding: 0 0 14px; overflow: hidden; align-items: start; height: 100%; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); transition: transform 0.2s, box-shadow 0.2s; }
  .lesson-card img { width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 0; }
  .lc-text { padding: 12px 16px 0; }
}

/* ---------- Player shell ---------- */
.icon-btn { display: inline-grid; place-items: center; min-width: 44px; height: 44px; border-radius: 14px; color: var(--ink); text-decoration: none; transition: background 0.15s; }
.stage-wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.theatre { position: relative; min-width: 0; }

/* ---------- Scene ---------- */
.scene { position: relative; overflow: hidden; width: 100%; aspect-ratio: 3 / 2; margin: 0 auto; border-radius: 18px; background: #e9e1d2; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.camera { position: absolute; inset: 0; }
.camera img { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; max-width: none; opacity: 0; transition: opacity 0.5s; }
.camera img.ready { opacity: 1; }
.scene.full-bleed { border-radius: 0; }
.scene-tint { position: absolute; inset: 0; pointer-events: none; background: var(--scrim); opacity: 0; transition: opacity 0.35s; }
.scene[data-mode="pick"] .scene-tint, .scene[data-mode="done"] .scene-tint { opacity: 1; }
.scene[data-mode="pick"] .scene-tint { opacity: 0.5; }
.bubbles, .faces { position: absolute; inset: 0; pointer-events: none; }
.bubbles { --bfs: 20px; }

/* Speech bubbles: drawn in the art's own ink, on warm paper */
.bubble { position: absolute; left: 0; top: 0; max-width: min(46%, 460px); padding: 0.62em 0.95em 0.7em; border: 2.5px solid var(--bubble-line); border-radius: 1.5em 1.35em 1.6em 1.25em / 1.35em 1.55em 1.3em 1.5em; background: var(--bubble); color: var(--bubble-ink); box-shadow: 3px 4px 0 rgb(20 33 31 / 0.16); font-size: var(--bfs); pointer-events: auto; transition: opacity 0.35s, filter 0.35s, scale 0.35s cubic-bezier(.2,.8,.2,1.15); transform-origin: var(--tail-x, 50%) 100%; }
.bubble.enter { animation: pop 0.38s cubic-bezier(.2,.9,.3,1.25) both; }
@keyframes pop { from { opacity: 0; scale: 0.82; } to { opacity: 1; scale: 1; } }
.bubble.prev { font-size: calc(var(--bfs) * 0.84); opacity: 0.86; filter: saturate(0.8); box-shadow: 2px 3px 0 rgb(20 33 31 / 0.12); }
.bubble.prev .bubble-text { color: #34413e; }
.bubble.compact .bubble-text { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.bubble-name { position: absolute; top: -0.85em; left: 0.9em; display: inline-flex; align-items: baseline; gap: 6px; padding: 0.1em 0.6em 0.14em; border-radius: 999px; background: var(--spk); color: #fff; font-size: 13px; line-height: 1.35; font-weight: 600; white-space: nowrap; box-shadow: 0 1px 0 rgb(0 0 0 / 0.12); }
.bubble-name small { font-size: 11.5px; font-weight: 500; opacity: 0.85; }
.bubble[data-side="right"] .bubble-name { left: auto; right: 0.9em; }
.bubble-text { margin: 0.18em 0 0; font-weight: 500; line-height: 1.32; letter-spacing: 0.002em; overflow-wrap: break-word; }
.bubble-row { display: flex; align-items: flex-start; gap: 0.35em; }
.bubble-row .bubble-text { flex: 1; }
.bubble-play { flex: none; display: grid; place-items: center; width: 34px; height: 34px; margin: -0.05em -0.45em -0.2em 0; border-radius: 50%; color: var(--spk); }
.bubble-play svg { width: 19px; height: 19px; }
.bubble.prev .bubble-play { width: 30px; height: 30px; }
.tail { position: absolute; top: calc(100% - 3px); width: 34px; height: 24px; overflow: visible; pointer-events: none; }
.tail path { fill: var(--bubble); stroke: var(--bubble-line); stroke-width: 2.5; stroke-linejoin: round; }
.bubble.prev .tail { opacity: 1; }
.bubble.no-tail .tail { display: none; }

/* words: karaoke + key phrase marker */
.w { transition: opacity 0.14s, color 0.14s; border-radius: 3px; }
.karaoke .w { opacity: 0.34; }
.karaoke .w.said { opacity: 1; }
.karaoke .w.on { color: var(--spk); }
.ph { background-image: linear-gradient(transparent 68%, rgb(246 201 101 / 0.62) 68%, rgb(246 201 101 / 0.62) 94%, transparent 94%); }
.bubble.prev .ph { background-image: none; }

/* your line, veiled until you peek or record */
.bubble.mine { border-style: dashed; border-color: var(--spk); box-shadow: 0 0 0 5px color-mix(in srgb, var(--spk) 16%, transparent), 3px 4px 0 rgb(20 33 31 / 0.14); }
.bubble.mine .tail path { stroke: var(--spk); stroke-dasharray: 5 4; }
.veil { position: relative; }
.veiled .bubble-text { filter: blur(0.32em); opacity: 0.55; }
.peek { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; }
.peek .hint { background: var(--bubble); color: var(--bubble-ink); box-shadow: inset 0 0 0 1.5px var(--bubble-line), 0 2px 8px rgb(0 0 0 / 0.12); }
.peek button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: var(--bubble-ink); color: var(--bubble); font-size: 14px; font-weight: 600; box-shadow: 0 2px 8px rgb(0 0 0 / 0.2); }
.peek button svg { width: 17px; height: 17px; }
.peek .hint .vi-bubble { width: 21px; height: 17px; }
.vi-bubble path { fill: #f2a33a; stroke: none; }
.vi-bubble text { fill: #1a0e00; stroke: none; font-family: inherit; font-size: 8.2px; font-weight: 800; letter-spacing: 0.2px; text-anchor: middle; }
.meter { display: flex; align-items: center; gap: 3px; height: 28px; margin-top: 0.35em; }
.meter i { flex: 1; max-width: 6px; height: 4px; border-radius: 3px; background: var(--rec); transition: height 0.06s; }
.meter-time { margin-left: 8px; font-size: 13px; color: var(--rec); font-variant-numeric: tabular-nums; white-space: nowrap; }
.take { display: flex; align-items: center; gap: 6px; margin-top: 0.3em; font-size: 13px; color: var(--spk); }
.take svg { width: 15px; height: 15px; stroke-width: 2.4; }

/* cast tags on the intro */
.bubble.tag { padding: 0.45em 0.85em 0.5em; font-size: calc(var(--bfs) * 0.9); }
.bubble.tag .bubble-text { margin: 0; line-height: 1.2; }
.bubble.tag .role { display: block; font-size: 0.68em; color: #5b6a67; margin-top: 2px; }

/* choose a person */
.face-target { position: absolute; pointer-events: auto; display: grid; justify-items: center; gap: 8px; translate: -50% -50%; }
.face-ring { width: var(--ring); height: var(--ring); border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 4px var(--spk), 0 0 0 9px color-mix(in srgb, var(--spk) 35%, transparent), 0 10px 30px rgb(0 0 0 / 0.35); background: transparent; animation: ring 1.8s ease-in-out infinite; }
.face-target:hover .face-ring, .face-target:focus-visible .face-ring { box-shadow: 0 0 0 5px var(--spk), 0 0 0 14px color-mix(in srgb, var(--spk) 45%, transparent), 0 10px 30px rgb(0 0 0 / 0.35); }
.face-target:focus-visible { outline: none; }
.face-label { padding: 6px 14px; border-radius: 999px; background: var(--spk); color: #fff; font-weight: 600; font-size: 15px; white-space: nowrap; box-shadow: 0 6px 16px rgb(0 0 0 / 0.25); }
.face-label small { font-weight: 500; opacity: 0.85; }
@keyframes ring { 50% { scale: 1.06; } }
.scene-note { position: absolute; left: 50%; top: 16px; translate: -50% 0; z-index: 3; padding: 8px 16px; border-radius: 999px; background: var(--bubble); color: var(--bubble-ink); border: 2px solid var(--bubble-line); font-size: 15px; font-weight: 600; white-space: nowrap; box-shadow: 3px 4px 0 rgb(20 33 31 / 0.16); }

/* ---------- End panel (mobile EndPanel): rises over the scene, Mầm cheering on top ---------- */
.finale { position: absolute; inset: 0; z-index: 6; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; }
.finale:focus { outline: none; }
.end { position: relative; width: 100%; max-height: 100%; padding-top: 64px; display: flex; flex-direction: column; animation: rise 0.45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes rise { from { opacity: 0; translate: 0 40px; } }
.end-mam { position: absolute; top: 0; left: 50%; translate: -50% 0; z-index: 1; width: 92px; pointer-events: none; }
.end-panel { min-height: 0; overflow: auto; display: grid; gap: 12px; padding: 50px 20px max(16px, env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; background: var(--surface); box-shadow: 0 -8px 30px rgb(14 36 32 / 0.18); scrollbar-width: thin; }
.end-head { text-align: center; }
.end-head h2 { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 700; }
.end-head p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
/* "Khoe thành tích" (after speaking) or "Chia sẻ hội thoại" (after listening): a small tonal pill under the title. */
.end-share { justify-self: center; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-top: -2px; padding: 0 18px 0 14px; border-radius: 999px; background: var(--primary-soft); color: #00594f; font-size: 15.5px; font-weight: 700; }
.end-share svg { width: 20px; height: 20px; stroke-width: 2; }
@media (hover: hover) { .end-share:hover { background: color-mix(in srgb, var(--primary-soft) 82%, var(--primary)); } }
/* One Mầm on screen: the share sheet brings its own. */
.finale.is-sharing .end-mam { visibility: hidden; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 10px 12px; border-radius: 16px; background: var(--surface-2); text-align: center; }
.stat b { display: block; font-size: 22px; line-height: 1.15; }
.stat span { font-size: 12.5px; color: var(--muted); }
.stat.alert b { color: var(--rec); }
.phrases { display: grid; gap: 8px; }
.ph-head { display: flex; align-items: center; gap: 8px; }
.ph-head > div { flex: 1; min-width: 0; }
.ph-title { margin: 0; font-size: 16px; font-weight: 700; }
.ph-note { margin: 1px 0 0; font-size: 13px; color: var(--muted); }
.ph-note.error { color: var(--rec); }
.group { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); overflow: hidden; }
.group > li + li { border-top: 1px solid var(--line); }
.pi { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); flex: none; transition: background 0.2s, color 0.2s; }
.pi svg { width: 18px; height: 18px; }
.pi.on { background: var(--primary); color: var(--on-primary); }
.save { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--muted); flex: none; }
.save svg { width: 24px; height: 24px; }
.save.on { color: var(--streak); }
.save.pop svg { animation: pop-save 0.42s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop-save { 40% { scale: 1.28; } }
.text-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: 999px; color: var(--primary); font-size: 14.5px; font-weight: 600; flex: none; }
.text-btn svg { width: 18px; height: 18px; }
/* The end card's phrases are the saved screen's rows (.srow); a short window gives them less air. */
@media (max-height: 500px) {
  .end-panel { padding-inline: 14px; }
  .phrases .srow-main { gap: 10px; padding: 8px 8px 8px 10px; }
  .phrases .srow .save { margin-top: 2px; }
}
@container conv (min-width: 700px) {
  .finale { align-items: center; padding: 24px; }
  .end { width: min(100%, 540px); max-height: 100%; }
  .end-panel { border-radius: 28px; box-shadow: var(--shadow-lg); padding-bottom: 20px; }
  .end-mam { width: 104px; }
}

/* avatars cut from the scene itself */
.avatar { display: inline-block; flex: none; width: var(--size, 40px); height: var(--size, 40px); border-radius: 50%; background-repeat: no-repeat; box-shadow: 0 0 0 2.5px var(--spk); }

/* ---------- Dock (mobile ConversationDock): one state at a time, under the scene ---------- */
.deck { position: relative; display: flex; flex-direction: column; gap: 8px; height: var(--deck); padding: 10px var(--gutter) max(12px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(14 36 32 / 0.06); }
.deck[data-mode="done"] { visibility: hidden; }
.track { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; flex: none; }
.track.long { gap: 2px; }
.track li { flex: 1; }
.track button { display: block; width: 100%; padding: 6px 0; }
.track button::before { content: ''; display: block; height: 5px; border-radius: 4px; background: var(--line); transition: background 0.2s, height 0.2s; }
.track [data-spk="A"] { --spk: var(--a); }
.track [data-spk="B"] { --spk: var(--b); }
.track .done::before { background: color-mix(in srgb, var(--spk) 55%, transparent); }
.track .now::before { background: var(--spk); height: 7px; margin-top: -1px; }
.track .mine:not(.done):not(.now)::before { background: transparent; box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--spk) 70%, transparent); }
.track .skipped::before { background: color-mix(in srgb, var(--spk) 28%, transparent); }
.track button:disabled { opacity: 1; cursor: default; }
.dock { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.dk-msg { margin: auto 0; text-align: center; color: var(--muted); font-size: 15px; }
.st { min-width: 0; }
.st-title { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 15.5px; line-height: 1.3; }
.st-title b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--spk); flex: none; }
.st-icon { display: inline-grid; flex: none; }
.st-icon svg { width: 17px; height: 17px; }
.st-detail { margin: 2px 0 0; font-size: 13px; line-height: 1.35; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.st-detail.flash { color: var(--ink); }
.dk-intro { display: grid; gap: 4px; }
.dk-meta { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dk-summary { margin: 0; font-size: 15px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dk-head { display: flex; align-items: flex-start; gap: 8px; }
.dk-head > div { flex: 1; min-width: 0; }
.dk-title { margin: 0; font-size: 17px; font-weight: 700; }
.dk-hint { margin: 1px 0 0; font-size: 13px; color: var(--muted); }
.dk-row { display: flex; align-items: center; gap: 8px; }
.dk-row.two > * { flex: 1 1 0; min-width: 0; }
.grow { flex: 1; }
.dk-transport { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.dk-transport > .tool:first-child { justify-self: start; }
.dk-transport > .tool:last-child { justify-self: end; }
.dk-center { display: flex; align-items: center; gap: 6px; }
.dk-turn { display: flex; align-items: center; gap: 12px; }
.dk-turn-text { flex: 1; min-width: 0; display: grid; gap: 4px; }
.rec-row { display: flex; align-items: center; gap: 8px; }
.rec-clock { font-size: 14px; font-variant-numeric: tabular-nums; }
.lv { flex: 1; display: flex; align-items: center; gap: 3px; height: 24px; }
.lv i { flex: 1; height: 3px; border-radius: 3px; background: var(--rec); transition: height 0.06s; }

/* the big round action (64 px), a ring pulsing while recording */
.big-wrap { position: relative; display: grid; place-items: center; width: 72px; height: 72px; flex: none; }
.big-wrap.pulse::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: color-mix(in srgb, var(--c) 18%, transparent); animation: grow 0.9s ease-in-out infinite alternate; }
@keyframes grow { to { scale: 1.22; } }
.big { position: relative; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--c); color: #fff; box-shadow: 0 3px 10px color-mix(in srgb, var(--c) 35%, transparent); transition: transform 0.15s, filter 0.15s; }
.big:active:not(:disabled) { transform: scale(0.95); }
.big:disabled { opacity: 1; }
.big svg { width: 30px; height: 30px; }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgb(255 255 255 / 0.4); border-top-color: #fff; animation: spin 0.8s linear infinite; }
@keyframes spin { to { rotate: 1turn; } }
.nav { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: var(--ink); }
.nav svg { width: 30px; height: 30px; }
.tool { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 64px; min-height: 52px; padding: 4px 6px; border-radius: 14px; color: var(--ink); text-decoration: none; }
.tool > span:last-child { font-size: 12.5px; line-height: 1.15; color: var(--muted); white-space: nowrap; }
.tool[aria-pressed="true"] svg { color: var(--primary); }
.tool svg { width: 24px; height: 24px; }
.tool .badge-num { font-size: 17px; font-weight: 700; line-height: 24px; }

/* the app's pill buttons: primary filled, secondary outlined, small */
.pill { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 20px; border-radius: 999px; font-size: 16px; font-weight: 600; white-space: nowrap; text-decoration: none; transition: background 0.15s, transform 0.15s; }
.pill > span { overflow: hidden; text-overflow: ellipsis; }
.pill:active:not(:disabled) { transform: scale(0.97); }
.pill.primary { background: var(--primary); color: var(--on-primary); }
.pill.outline { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
.pill.outline svg { color: var(--primary); }
.pill.block { width: 100%; }
.pill svg { width: 21px; height: 21px; flex: none; }
.spill { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; white-space: nowrap; flex: none; text-decoration: none; }
.spill svg { width: 18px; height: 18px; color: var(--primary); }
.spill.filled { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.spill.filled svg { color: currentColor; }
.icon-round { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: var(--muted); flex: none; }
.icon-round svg { width: 22px; height: 22px; }

/* role cards: a face cut from the scene, the name, the role, the lines or where to resume */
.role-card { display: flex; align-items: center; gap: 10px; min-height: 72px; padding: 10px; border-radius: 18px; background: var(--surface); border: 1.5px solid color-mix(in srgb, var(--spk) 55%, transparent); text-align: left; line-height: 1.25; }
.rc-text { min-width: 0; display: grid; }
.rc-text strong { font-size: 15.5px; }
.rc-text small { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-text .rc-count { font-weight: 600; }
.rc-text .resume { color: var(--primary); }

/* ---------- Side translation ---------- */
.side { display: none; }
.side-inner { display: flex; flex-direction: column; min-height: 0; height: 100%; padding: 16px 16px 20px; }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.side-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.side-body { flex: 1; min-height: 0; overflow: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; }
.now { padding: 14px 16px 16px; border-radius: 18px; background: var(--primary-soft); color: var(--on-primary-soft); margin-bottom: 14px; }
.now-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; opacity: 0.9; }
.now-label svg { width: 16px; height: 16px; }
.now-text { margin: 6px 0 0; font-size: 21px; line-height: 1.35; font-weight: 500; }
.now.yours { background: color-mix(in srgb, var(--rec) 10%, var(--surface)); color: var(--ink); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--rec) 35%, transparent); }
.now.yours .now-label { color: var(--rec); }
.side-label { margin: 6px 4px 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.lines { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 2px; }
.line { display: grid; grid-template-columns: 4px 1fr; gap: 10px; width: 100%; padding: 8px 10px 8px 6px; border-radius: 12px; text-align: left; }
.line::before { content: ''; border-radius: 4px; background: var(--spk); opacity: 0.55; }
.line .who-name { display: block; font-size: 12px; color: var(--muted); }
.line .tx { display: block; font-size: 15px; line-height: 1.4; }
.line.future { color: var(--faint); }
.line.future::before { opacity: 0.25; }
.line.is-now { background: var(--surface-2); }
.line.is-now::before { opacity: 1; }
.line:disabled { opacity: 1; cursor: default; }
.line.hidden-hint .tx { filter: blur(5px); }
.gloss { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gloss li { padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.gloss .en { display: block; font-size: 13px; color: var(--muted); }
.gloss .tx { display: block; font-size: 15.5px; }
.side-empty { padding: 18px 16px; border-radius: 18px; background: var(--surface-2); color: var(--muted); font-size: 14.5px; }
.side-error { padding: 14px 16px; border-radius: 16px; background: color-mix(in srgb, var(--rec) 10%, var(--surface)); font-size: 14.5px; }
.side-error button { margin-top: 8px; color: var(--primary); font-weight: 600; text-decoration: underline; }
.side-close { display: inline-grid; }

/* drawer (phones, tablets) */
.drawer { font: 500 16px/1.5 var(--font); position: fixed; inset: 0 0 0 auto; width: min(88vw, 400px); height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); padding-top: env(safe-area-inset-top); }
.drawer[open] { animation: slide 0.28s cubic-bezier(.2,.8,.2,1); }
.drawer::backdrop { background: var(--scrim); }
@keyframes slide { from { translate: 100% 0; } }

/* ---------- Saved phrases (mobile SavedPhrasesScreen) ---------- */
.saved { max-width: 1080px; margin: 0 auto; padding: 0 0 32px; }
.saved-sum { margin: 0 0 8px; font-size: 13.5px; color: var(--muted); }
.saved-groups { display: grid; gap: 8px; }
.sgroup { min-width: 0; }
.sg-head { display: flex; align-items: center; gap: 12px; margin: 8px 0 8px; padding: 4px; border-radius: 14px; color: inherit; text-decoration: none; }
.sg-head img, .sg-thumb { width: 60px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; background: var(--primary-soft); }
.sg-thumb { display: grid; place-items: center; color: var(--primary); }
.sg-text { flex: 1; min-width: 0; display: grid; }
.sg-text strong { font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-text small { font-size: 13px; color: var(--muted); }
.sg-head > svg { color: var(--muted); }
.srow { display: flex; align-items: flex-start; padding-right: 4px; }
.srow-main { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 12px; padding: 12px 8px 12px 12px; text-align: left; }
.srow-main:disabled { opacity: 1; cursor: default; }
.srow-main .pi { margin-top: 2px; }
.srow-text { min-width: 0; display: grid; gap: 3px; padding-top: 4px; }
.s-en { font-size: 17px; font-weight: 600; line-height: 1.3; }
.s-vi { font-size: 15px; color: var(--muted); }
.s-line { margin-top: 4px; padding-left: 10px; border-left: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); font-size: 13.5px; color: var(--muted); }
.s-line b { color: var(--ink); font-weight: 700; }
.s-fail { font-size: 13px; color: var(--rec); }
.srow .save { margin-top: 6px; }
.empty { display: grid; justify-items: center; gap: 8px; max-width: 440px; margin: 6vh auto 0; padding: 0 16px; text-align: center; }
.empty-mam { width: 168px; margin-bottom: 8px; }
.empty h2 { margin: 0; font-size: 22px; font-weight: 700; }
.empty p { margin: 0 0 12px; color: var(--muted); }
.snack { position: fixed; left: 50%; bottom: calc(16px + var(--below, 0px) + env(safe-area-inset-bottom)); translate: -50% 0; z-index: 20; display: flex; align-items: center; gap: 16px; width: max-content; max-width: calc(100vw - 32px); padding: 12px 12px 12px 18px; border-radius: 12px; background: #1f2a28; color: #fff; box-shadow: var(--shadow-lg); font-size: 15px; animation: rise 0.25s ease-out both; }
.snack span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snack button { flex: none; padding: 6px 10px; border-radius: 8px; color: #7fd8c9; font-weight: 700; }
@container conv (min-width: 860px) {
  .saved-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 24px; align-items: start; }
}

/* ---------- Wide screens: scene + side column ---------- */
@container conv (min-width: 700px) {
  .player { --deck: 176px; }
  .scene { border-radius: 24px; }
  .deck { width: max(var(--scene-w, 100%), 560px); max-width: 100%; margin: 12px auto 0; padding: 12px 18px 14px; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
}
@container conv (min-width: 980px) {
  .stage-wrap { grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; }
  .stage-wrap.side-closed { grid-template-columns: minmax(0, 1fr); }
  .side { display: block; position: sticky; top: 12px; height: min(760px, calc(100svh - 140px)); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
  .stage-wrap.side-closed .side { display: none; }
}
@container conv (max-width: 699px) {
  .scene-note { font-size: 14px; top: 12px; }
}
@container conv (max-width: 380px) {
  .tool { min-width: 54px; padding: 4px 2px; }
  .pill { padding: 0 14px; font-size: 15px; }
  .nav { width: 40px; }
}

@media (hover: hover) {
  .today-card:hover img { transform: scale(1.025); }
  .lesson-card:hover { background: var(--surface-2); }
  .icon-btn:hover, .nav:hover:not(:disabled), .tool:hover:not(:disabled), .icon-round:hover, .save:hover, .text-btn:hover, .sg-head:hover { background: var(--surface-2); }
  .bubble-play:hover { background: color-mix(in srgb, var(--spk) 12%, transparent); }
  .srow-main:hover:not(:disabled) { background: var(--surface-2); }
  .big:hover:not(:disabled) { filter: brightness(0.92); }
  .pill.primary:hover:not(:disabled), .spill.filled:hover { background: var(--primary-hover); }
  .pill.outline:hover:not(:disabled), .spill:not(.filled):hover, .chip-filter:hover, .lang:hover { background: var(--surface-2); }
  .role-card:hover { border-color: var(--spk); background: color-mix(in srgb, var(--spk) 5%, var(--surface)); }
  .continue-card:hover { filter: brightness(0.98); }
  .line:hover:not(:disabled) { background: var(--surface-2); }
}
@container conv (min-width: 700px) { @media (hover: hover) {
  .lesson-card:hover { background: var(--surface); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
} }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
.bubbles.narrow .bubble { max-width: calc(100% - 24px); }
.bubbles.narrow .bubble.tag { max-width: 46%; }

/* PRO (one free conversation a day): the stories' lock badge and today's free tag. */
.story-pro { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 8px; background: var(--sn-lock, #b3261e); color: #fff; font-size: 12px; font-weight: 700; line-height: 16px; }
.story-pro svg { width: 13px; height: 13px; }
.lesson-card.is-locked img { filter: saturate(0.6); }
.free-today { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; background: rgb(255 255 255 / 0.22); color: #fff; font-size: 12.5px; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* The wide today card puts dark text on a plain surface (the same container query as its layout). */
@container conv (min-width: 860px) {
  .free-today { background: var(--primary-soft); color: var(--on-primary-soft); }
}
/* Under the chin (no room above the head): the same tail, flipped, from the top edge up to the face. */
.bubble.tail-up .tail { top: auto; bottom: calc(100% - 3px); transform: scaleY(-1); }
/* Listening (mobile dockHeight): the track and one row of controls, as tall as they are, at every
   width; no "Đã tạm dừng · Câu n" line. */
.deck[data-mode="listen"]:not(.has-status) { height: auto; }
.deck[data-mode="listen"]:not(.has-status) .dock { flex: none; }
/* The end card on wide screens: a wider card, the phrases in two columns. */
@container conv (min-width: 860px) {
  .end { width: min(100%, 820px); }
  .phrases .group { display: grid; grid-template-columns: 1fr 1fr; }
  .phrases .group > li + li { border-top: 0; }
  .phrases .group > li:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .phrases .group > li:nth-child(even) { border-left: 1px solid var(--line); }
}
.end-close { position: absolute; top: 72px; right: 8px; z-index: 2; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--ink, #1c2b28); }
.end-close:hover { background: var(--surface-2, rgb(0 0 0 / 0.05)); }
.end-close svg { width: 22px; height: 22px; }

/* ---------- Loading placeholders (mobile ConversationListSkeleton / SceneSkeleton) ----------
   The cards' own shapes with a light band sweeping across, instead of "Đang tải…" text. */
.sk, .today-card.sk {
  background: linear-gradient(110deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%) 0 0 / 300% 100%;
  animation: cv-shimmer 1.3s linear infinite;
}
.library img.is-loading {
  background: linear-gradient(110deg, var(--surface-2) 30%, var(--surface) 50%, var(--surface-2) 70%) 0 0 / 300% 100%;
  animation: cv-shimmer 1.3s linear infinite;
}
.scene.is-loading {
  background: linear-gradient(110deg, #e9e1d2 30%, #f7f2e8 50%, #e9e1d2 70%) 0 0 / 300% 100%;
  animation: cv-shimmer 1.3s linear infinite;
}
@keyframes cv-shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  .sk, .today-card.sk, .scene.is-loading, .library img.is-loading { animation: none; }
}
.today-card.sk { box-shadow: none; border: 0; pointer-events: none; }
.today-card.sk::after { display: none; }
.sk-row .lesson-card { pointer-events: none; }
.sk-thumb { display: block; width: 112px; height: 75px; border-radius: 12px; }
.sk-line { display: block; height: 14px; margin: 4px 0 8px; border-radius: 7px; }
.sk-line.w75 { width: 75%; height: 16px; }
.sk-line.w50 { width: 50%; }
.sk-chip { display: block; width: 44px; height: 20px; border-radius: 999px; }
.sk-pill { display: block; width: 180px; height: 48px; border-radius: 999px; }
.dk-skel { display: grid; justify-items: center; gap: 12px; width: 100%; margin: auto 0; }
.dk-skel .sk-line { width: 50%; max-width: 240px; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@container conv (min-width: 700px) {
  .sk-thumb { width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 0; }
  .sk-row .lc-text { padding: 12px 16px 0; }
}
@container conv (min-width: 860px) {
  .today-card.sk { display: block; aspect-ratio: 2.65 / 1; }
}
/* "Chạm để tra từ": each English word in a line opens in the dictionary sheet. */
.bubble:not(.veiled) .bubble-text .w { cursor: pointer; }
@media (hover: hover) { .bubble:not(.veiled) .bubble-text .w:hover { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); text-underline-offset: 3px; } }
