/* Daily practice (the trip home). Light storybook paper: warm cream ground,
   white cards, uniform-blue ink, vermilion for the mic, gold for "in
   progress", and one soft pastel per trip section (from the gouache palette).
   Icons over labels; every icon button carries an aria-label. Phone-first,
   widened for desktop. */
.trip-screen {
  --bg: #f7f2ea; --surface: #ffffff; --surface-2: #f3ede3; --surface-3: #e9e1d4;
  --line: rgba(52, 38, 24, 0.1);
  --text: #1d1a26; --muted: #564f60; --faint: #8a8290;
  --ink: #1d1a26; --on-ink: #ffffff;
  --gold: #5f9e7f; --gold-soft: #dcefe3; --lavender: #5f9e7f; --blue: #2c5a47;
  --mic: #e0523a; --ok: #2d7355; --ok-soft: #d7ecdf; --warn: #c2412d;
  --tint: #e1eee4; --tint-ink: #2f5d49;
  --shadow: 0 1px 2px rgba(52, 38, 24, 0.06), 0 8px 24px rgba(52, 38, 24, 0.07);
  --r: 22px; --tap: 44px;
  color-scheme: light;
  height: 100%; overflow-y: auto;
  background: var(--bg); color: var(--text);
  padding: max(12px, env(safe-area-inset-top)) max(16px, calc((100vw - 1080px) / 2)) max(24px, env(safe-area-inset-bottom));
  font-size: 1rem; line-height: 1.5;
}
/* Each trip section gets its own pastel, used for its hero, tiles and scene. */
.trip-screen [data-group="family"], .trip-convo[data-group="family"] { --tint: #e1eee4; --tint-ink: #2f5d49; }
.trip-screen [data-group="prep"], .trip-convo[data-group="prep"] { --tint: #fdf0c4; --tint-ink: #7a5a00; }
.trip-screen [data-group="train"], .trip-convo[data-group="train"] { --tint: #dbe9f8; --tint-ink: #25486f; }
.trip-screen [data-group="stay"], .trip-convo[data-group="stay"] { --tint: #dcecd8; --tint-ink: #2f5d34; }
.trip-screen [data-group="sights"], .trip-convo[data-group="sights"] { --tint: #fde2d2; --tint-ink: #8a3c17; }
.trip-screen [data-group="food"], .trip-convo[data-group="food"] { --tint: #fbdadf; --tint-ink: #8a2a3b; }
.trip-screen [data-group="care"], .trip-convo[data-group="care"] { --tint: #f3e3d6; --tint-ink: #7a4526; }
.trip-screen [data-group="everyday"], .trip-convo[data-group="everyday"] { --tint: #ece6dc; --tint-ink: #5a4d3c; }
.trip-screen * { box-sizing: border-box; }
.trip-screen [hidden] { display: none !important; }
/* Zero-specificity resets, so component classes always win. */
:where(.trip-screen) :where(h1, h2, h3, p, ul) { margin: 0; }
:where(.trip-screen) :where(ul) { padding: 0; list-style: none; }
.trip-screen .han { font-family: var(--han); }
.trip-screen button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.trip-screen button:disabled { cursor: default; opacity: 0.45; }
.trip-screen :is(button, textarea):focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.trip-muted { color: var(--muted); font-size: 0.88rem; }
.ti { width: 20px; height: 20px; flex: none; }

/* icon buttons */
.trip-ibtn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); padding: 0;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); transition: background 0.15s, color 0.15s, transform 0.15s; }
.trip-ibtn:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.trip-ibtn:active:not(:disabled), .trip-go:active:not(:disabled) { transform: scale(0.96); }
.trip-glyph { font-family: var(--han); font-size: 0.95rem; font-weight: 700; letter-spacing: 0; }
.trip-glyph[aria-pressed="true"] { color: var(--text); background: var(--surface-3); }
.trip-screen .trip-go { min-height: 50px; padding: 0 22px; border: 0; border-radius: 999px; background: var(--ink); color: var(--on-ink);
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: transform 0.15s, filter 0.15s; }
.trip-go:hover:not(:disabled) { filter: brightness(1.25); }
.trip-go .ti { width: 18px; height: 18px; }
.trip-screen .trip-link { border: 0; border-radius: 999px; background: none; color: var(--muted); min-height: 44px; padding: 0 16px; margin-top: 2px; font-size: 0.86rem; font-weight: 500; color: var(--faint); text-decoration: underline; text-underline-offset: 3px; }

/* ruby pinyin */
.trip-screen ruby { ruby-position: over; }
.trip-screen rt { font-family: -apple-system, "Segoe UI", sans-serif; font-size: 0.46em; letter-spacing: 0; color: #5f5868; padding: 0 0.08em; letter-spacing: 0; line-height: 1; }
/* display:none (not visibility) so hidden pinyin stops widening its character. */
.trip-screen.hide-py rt { display: none; }
.trip-screen.hide-py .py { display: none; }
.trip-screen .zh { font-size: 1.3rem; line-height: 2.05; text-wrap: pretty; }
.trip-word { display: inline-block; white-space: nowrap; }
.trip-word[data-trip-word] { border-radius: 5px; cursor: pointer; -webkit-tap-highlight-color: rgba(47, 93, 73, 0.12); }
.trip-word[data-trip-word]:focus-visible { outline: 2px solid var(--tint-ink); outline-offset: 3px; background: var(--tint); }
.trip-word-tip { position: fixed; z-index: 48; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1px 8px;
  width: max-content; max-width: min(260px, calc(100vw - 16px)); padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--tint-ink) 26%, transparent);
  border-radius: 14px; background: #fffdf8; color: var(--text); box-shadow: 0 10px 28px rgba(52, 38, 24, 0.18); text-align: left; pointer-events: none; }
.trip-word-tip .trip-word-zh { font-size: 1.08rem; line-height: 1.25; }
.trip-word-tip .trip-word-py { align-self: end; color: var(--tint-ink); font-size: 0.78rem; line-height: 1.3; }
.trip-word-tip .trip-word-en { grid-column: 1 / -1; color: var(--muted); font-size: 0.82rem; line-height: 1.3; }
.trip-word-tip .trip-word-part { grid-column: 1 / -1; margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; line-height: 1.3; }
.trip-word-tip .trip-word-part b { color: var(--text); font-weight: 600; }
.trip-word.is-phrase { background: var(--tint); box-shadow: 0 0 0 2px var(--tint); }
.trip-char [data-trip-word] { transition: opacity 90ms linear, color 90ms linear; }
.trip-char [data-trip-word].is-pending { opacity: 0; pointer-events: none; }
.trip-char [data-trip-word].is-current { opacity: 1; color: var(--tint-ink); text-decoration: underline; text-decoration-thickness: 0.12em; text-underline-offset: 0.18em; }
.trip-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.trip-option-en, .trip-en { text-wrap: pretty; }
.trip-say > .trip-option-en { text-wrap: balance; }
.trip-screen .py { color: var(--muted); font-size: 0.85rem; }

/* top bar (both screens) */
.trip-bar { display: flex; align-items: center; gap: 10px; min-height: 52px; margin: 0 0 14px; }
.trip-screen .trip-bar > .trip-ibtn:first-child { background: var(--surface-3); color: var(--text); }
.trip-bar-title { flex: 1; min-width: 0; }
.trip-bar-title h1 { font-size: 1.15rem; font-weight: 750; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-bar-title p { color: var(--muted); font-size: 0.85rem; }
.trip-bar-tools { display: flex; align-items: center; gap: 6px; }
.trip-bar-tools .trip-glyph { width: var(--tap); height: var(--tap); background: var(--surface-3); box-shadow: none; }
.trip-bar-tools .trip-glyph[aria-pressed="true"] { background: var(--surface-3); box-shadow: none; }
.trip-screen .trip-words-btn { display: inline-grid; place-items: center; width: var(--tap); min-height: var(--tap); padding: 0; border: 0; border-radius: 999px;
  background: var(--surface-3); color: var(--text); font-size: 0.88rem; font-weight: 700; transition: background 0.15s, color 0.15s; }

/* simplified/traditional picker */
.trip-script-picker { position: relative; }
.trip-script-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; list-style: none; margin: 0; padding: 6px;
  min-width: 176px; background: var(--surface-2); border-radius: 12px; box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2); }
.trip-script-opt { display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font-size: 0.9rem; }
.trip-script-opt:hover { background: var(--surface-3); }
.trip-script-opt.is-sel { font-weight: 750; }


/* ---------- home ---------- */
.trip-home .trip-bar { align-items: flex-end; min-height: 70px; margin: 0 0 16px; }
.trip-home .trip-bar-title h1 { font-size: clamp(1.9rem, 7vw, 2.4rem); line-height: 1.05; letter-spacing: -0.035em; }
.trip-home .trip-bar-title p { margin-top: 6px; font-size: 0.92rem; }

.trip-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 128px; align-items: center; gap: 8px; min-height: 200px;
  padding: 20px 0 20px 20px; border-radius: var(--r); background: var(--tint); overflow: hidden; margin-bottom: 14px; }
.trip-hero-copy { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; min-width: 0; }
.trip-hero h2 { margin-top: 0; font-size: 1.35rem; line-height: 1.2; letter-spacing: -0.02em; font-weight: 750; }
.trip-hero-zh { margin-top: 2px; color: var(--muted); font-size: 0.92rem; }
.trip-hero-meter { width: 100%; max-width: 180px; height: 6px; margin-top: 14px; border-radius: 999px; background: rgba(29, 26, 38, 0.12); overflow: hidden; }
.trip-hero-meter span { display: block; height: 100%; border-radius: inherit; background: var(--ink); }
.trip-hero-go { margin-top: 16px; }
.trip-hero-art { position: relative; z-index: 1; align-self: center; justify-self: center; margin-right: 16px; }
.trip-hero-face { display: block; width: 108px; height: 108px; border-radius: 30px; overflow: hidden; box-shadow: 0 10px 24px rgba(40, 20, 60, 0.14); }
.trip-hero-face img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.16); }
.trip-hero-others { position: absolute; right: 6px; bottom: 6px; display: flex; }
.trip-hero-others .trip-stack-face { width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid #fff; overflow: hidden; background: #fff; }
.trip-hero-others .trip-stack-face + .trip-stack-face { margin-left: -12px; }
.trip-stack-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.trip-stack-face img.is-cutout { height: 130%; object-position: center 6%; }

.trip-group { margin-top: 10px; border-radius: var(--r); background: var(--surface); }
.trip-group:first-of-type { margin-top: 20px; }
.trip-group[open] .trip-list { gap: 0; padding: 0 8px 8px; }
.trip-group[open] .trip-row { box-shadow: none; border-radius: 16px; min-height: 76px; }
.trip-group[open] .trip-list > li + li { position: relative; }
.trip-group[open] .trip-list > li + li::before { content: ""; position: absolute; pointer-events: none; top: 0; left: 76px; right: 12px; height: 1px; background: var(--line); }
.trip-group[open] .trip-soon { box-shadow: none; }
.trip-screen .trip-h2 { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px;
  font-size: 1rem; font-weight: 750; letter-spacing: -0.01em; color: var(--text); border-radius: var(--r); }
.trip-h2::-webkit-details-marker { display: none; }
.trip-h2 > .ti { width: 18px; height: 18px; color: var(--muted); transform: rotate(90deg); transition: transform 0.32s cubic-bezier(.22,.8,.24,1); }
.trip-group[open] > .trip-h2 > .ti { transform: rotate(-90deg); }
.trip-h2-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.trip-h2-faces { display: flex; flex: none; width: 84px; }
.trip-h2-faces .trip-stack-face { width: 36px; height: 36px; border-radius: 11px; border: 2px solid var(--surface); overflow: hidden; background: #fff; }
.trip-h2-faces .trip-stack-face + .trip-stack-face { margin-left: -12px; }
.trip-h2 .han { flex: none; }
.trip-h2 .han { color: var(--muted); font-weight: 500; font-size: 0.82rem; }
.trip-group-count { flex: none; color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.trip-overview { display: grid; gap: 8px; padding: 18px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.trip-overview-head { display: flex; justify-content: space-between; align-items: baseline; }
.trip-overview-head strong { font-size: 1.02rem; letter-spacing: -0.01em; }
.trip-overview-head span { color: var(--muted); font-size: 0.86rem; font-weight: 650; }
.trip-overview-legend { display: flex; flex-wrap: wrap; gap: 5px 14px; }
.trip-overview-legend > span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.72rem; }
.trip-overview-legend .trip-dot { width: 10px; height: 10px; min-width: 10px; border-radius: 50%; }
.trip-overview-row { min-height: 30px; display: grid; grid-template-columns: minmax(90px, 1fr) auto; gap: 10px; align-items: center; }
.trip-screen .trip-overview-label { min-width: 0; display: flex; align-items: center; gap: 7px; min-height: 32px; padding: 0; border: 0; background: none; text-align: left; }
.trip-overview-label::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--tint-ink); opacity: 0.55; }
.trip-overview-label strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.82rem; font-weight: 650; }
.trip-overview-label span { color: var(--faint); font-size: 0.72rem; }
.trip-overview-strip { display: flex; flex-wrap: nowrap; gap: 0; border-radius: 999px; overflow: hidden; margin: 6px 0 2px; padding: 0; }
.trip-overview-dots { display: contents; }
.trip-overview-strip .trip-dot { flex: 1 1 0; width: auto; min-width: 0; height: 12px; border-radius: 0; box-shadow: inset -1px 0 0 rgba(255,255,255,0.7); }
.trip-dot { width: 14px; height: 10px; min-width: 0; padding: 0; border: 0; border-radius: 3px; background: #e2dacd; }
button.trip-dot { cursor: pointer; }
.trip-dot.is-done { background: var(--ok); }
.trip-dot.is-going { background: var(--gold); }
.trip-dot.is-new { background: #e2dacd; }
.trip-dot.is-soon { background: repeating-linear-gradient(-45deg, #b9ab97 0 2px, #efe8dc 2px 4px); }
.trip-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.trip-tag { display: inline-flex; align-items: center; gap: 3px; min-height: 28px; padding: 0 11px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 650; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.trip-tag .ti { width: 14px; height: 14px; }
.trip-tag.is-done { color: var(--ok); background: var(--ok-soft); }
.trip-tag.is-going { color: #2f5d49; background: var(--gold-soft); }
.trip-tag.is-new { display: none; }
.trip-tag.is-soon { background: transparent; color: var(--faint); }
.trip-list { display: grid; gap: 8px; }
@media (min-width: 761px) {
  .trip-list { grid-template-columns: 1fr 1fr; column-gap: 16px; }
  .trip-group[open] .trip-list > li:nth-child(2)::before { display: none; }
  .trip-list > .trip-soon { grid-column: 1 / -1; }
}
.trip-row { width: 100%; display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left;
  padding: 8px 12px 8px 8px; min-height: 72px; border-radius: var(--r); border: 0; background: var(--surface);
  transition: background-color 0.15s; }
@media (hover: hover) { .trip-row:hover:not(:disabled) { background: var(--surface-2); } }
.trip-row:active:not(:disabled) { background: var(--surface-3); }
.trip-screen .trip-row:disabled { opacity: 1; background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: #4a4452; }
.trip-row:disabled .trip-row-face img { opacity: 0.7; filter: grayscale(0.5); }
.trip-row-face { position: relative; width: 56px; height: 56px; border-radius: 16px; background: var(--tint); overflow: visible; display: flex; align-items: flex-end; justify-content: center; }
.trip-row-pic { display: block; width: 100%; height: 100%; border-radius: 16px; overflow: hidden; }
.trip-row-pic img { width: 100%; height: 100%; object-fit: cover; display: block; transform: scale(1.16); }
.trip-row-pic img.is-cutout { transform: none; height: 118%; object-position: center 8%; }
.trip-row-badge { position: absolute; right: -6px; bottom: -6px; width: 26px; height: 26px; border-radius: 50%; overflow: hidden; border: 2px solid var(--surface); background: var(--tint); }
.trip-row-badge img { width: 100%; height: 100%; object-fit: cover; }
:is(.trip-row-face, .trip-row-badge, .trip-who-face, .trip-stack-face, .trip-say-face) img.is-photo { transform: scale(1.16); }
.trip-row-face { isolation: isolate; }
.trip-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.trip-row-num { margin-right: 6px; color: var(--faint); font-weight: 600; font-variant-numeric: tabular-nums; }
.trip-row-title { font-size: 0.93rem; font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.trip-row-zh { font-size: 0.8rem; line-height: 1.25; color: var(--muted); }
.trip-row.is-done .trip-row-title { color: var(--muted); }
.trip-soon { display: grid; gap: 2px; padding: 12px 16px; border-radius: var(--r); box-shadow: inset 0 0 0 1.5px dashed; box-shadow: inset 0 0 0 1.5px var(--line); }
.trip-soon-title { font-size: 0.88rem; font-weight: 700; color: #4a4452; }
.trip-soon-list { font-size: 0.8rem; color: var(--muted); line-height: 1.35; }

/* ---------- a conversation ---------- */
.trip-convo { --shadow: 0 1px 2px rgb(52 38 24 / 5%), 0 3px 9px rgb(52 38 24 / 4%);
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "bar" "stage" "dock"; height: 100%; overflow: hidden; }
.trip-convo .trip-bar { grid-area: bar; flex-wrap: wrap; row-gap: 10px; margin-bottom: 14px; }
.trip-progress { flex: 1 0 100%; height: 5px; border-radius: 999px; background: #ddd3c4; overflow: hidden; }
.trip-progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--gold); transition: width 0.4s ease; }

.trip-words-panel { position: fixed; z-index: 40; top: max(10px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right));
  width: min(390px, calc(100vw - 24px)); max-height: calc(100dvh - max(20px, env(safe-area-inset-top)) - max(12px, env(safe-area-inset-bottom)));
  overflow-y: auto; padding: 12px; border: 0; border-radius: 26px; background: var(--bg);
  box-shadow: 0 10px 28px rgb(30 20 40 / 15%); animation: trip-panel-in 0.2s ease-out; }
.trip-screen.words-open::before { content: ""; position: fixed; z-index: 39; inset: 0; background: rgba(38, 26, 18, 0.4); }
@keyframes trip-panel-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
.trip-words-head { position: sticky; top: -12px; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  min-height: 56px; padding: 10px 0 10px 2px; background: var(--bg); font-size: 1.15rem; font-weight: 750; letter-spacing: -0.01em; }
.trip-screen .trip-words-close { min-height: 38px; padding: 0 16px; margin-right: 0; border: 0; border-radius: 999px; background: var(--tint); color: var(--tint-ink); color: var(--text); font-weight: 700; font-size: 0.95rem; }
.trip-grab { position: absolute; top: 4px; left: 50%; width: 40px; height: 5px; margin-left: -20px; border-radius: 999px; background: #d6ccbd; }
.trip-targets ul { display: grid; gap: 8px; }
.trip-notes { margin-top: 18px; padding: 14px 16px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.trip-notes h2 { font-size: 0.9rem; font-weight: 750; margin-bottom: 6px; }
.trip-notes ul { display: grid; gap: 6px; padding-left: 18px !important; list-style: disc !important; font-size: 0.84rem; color: var(--muted); line-height: 1.4; }
.trip-target { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; text-align: left;
  min-height: 64px; padding: 12px 12px 10px 16px; border-radius: var(--r); border: 0; background: var(--surface); box-shadow: var(--shadow); transition: transform 0.15s; }
.trip-target:active { transform: scale(0.985); }
.trip-target .zh { font-size: 1.15rem; line-height: 1.8; }
.trip-target .py { color: var(--muted); font-size: 0.78rem; }
.trip-target-copy { min-width: 0; display: flex; flex-direction: column; }
.trip-target-en { display: block; padding: 0; color: var(--muted); font-size: 0.84rem; }
.trip-target-progress { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.trip-target-count { align-self: flex-start; margin-top: 2px; font-size: 0.8rem; font-weight: 500; color: var(--muted); }
.trip-target-count .pips { display: none; }
.trip-target-count .trip-sr { position: static; width: auto; height: auto; clip: auto; overflow: visible; }
.trip-target-progress .ti { width: 40px; height: 40px; padding: 10px; border-radius: 50%; background: var(--tint); color: var(--tint-ink); }
.pips { display: flex; gap: 4px; }
.pips i { width: 7px; height: 7px; border-radius: 50%; background: #d8cfc2; }
.pips i.on { background: var(--gold); }
.trip-targets li.is-mastered .trip-target { background: #f0faf5; }
.trip-targets li.is-mastered .pips i.on { background: var(--ok); }

.trip-stage { grid-area: stage; position: relative; min-height: 0; display: flex; flex-direction: column; }
.trip-history-toggle { align-self: flex-start; min-height: 34px; margin: 0 0 6px; padding: 0 12px; border: 0; border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 0.8rem; font-weight: 600; box-shadow: var(--shadow); }
.trip-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 12px;
  padding: 4px 4px 12px; scroll-behavior: smooth; }
.trip-char, .trip-me { max-width: min(560px, 92%); padding: 10px 12px 10px 14px; border-radius: var(--r); }
.trip-char { align-self: flex-start; background: var(--surface); box-shadow: var(--shadow); border-top-left-radius: 8px; }
.trip-me { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 8px; }
.trip-me rt, .trip-me .py, .trip-me .trip-en { color: rgba(255, 255, 255, 0.72); }
.trip-screen .trip-me .trip-ibtn { color: rgba(255, 255, 255, 0.8); }
.trip-me .trip-ibtn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.14); color: #fff; }
.trip-me .trip-badge { color: rgba(255, 255, 255, 0.7); }
.trip-me .trip-badge.ok { color: #9ff0cf; }
.trip-line-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; min-height: 32px; }
.trip-line-head > :first-child { flex: 1; min-width: 0; }
.trip-who { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; font-size: 0.86rem; font-weight: 750; color: var(--text); }
.trip-who-face { width: 30px; height: 30px; border-radius: 50%; background: var(--tint); overflow: hidden; flex: none; display: flex; justify-content: center; }
.trip-who-face img { width: 100%; height: 100%; object-fit: cover; }
.trip-who-face img.is-cutout { height: 140%; object-position: center 6%; }
.trip-who > .han { flex: none; }
.trip-who-en { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--faint); font-weight: 500; font-size: 0.76rem; }
.trip-tools { flex: none; display: flex; width: max-content; align-items: center; gap: 2px; margin: 0; padding: 2px; border-radius: 999px; background: var(--surface-2); }
.trip-screen .trip-tools .trip-ibtn { width: 34px; height: 30px; border-radius: 999px; background: transparent; color: var(--text); }
.trip-screen .trip-tools .trip-ibtn + .trip-ibtn { box-shadow: -1px 0 0 var(--surface-3); border-radius: 0 999px 999px 0; }
.trip-screen .trip-tools .trip-ibtn:not(:last-child) { border-radius: 999px 0 0 999px; }
.trip-screen .trip-tools .trip-ibtn + .trip-ibtn:not(:last-child) { border-radius: 0; }
.trip-screen .trip-tools .trip-glyph { font-size: 0.82rem; }
.trip-screen .trip-tools .ti { width: 16px; height: 16px; }
.trip-screen .trip-tools .trip-glyph { font-family: -apple-system, "Segoe UI", sans-serif; font-size: 0.7rem; font-weight: 800; }
.trip-screen .trip-tools .trip-glyph[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.trip-screen .trip-me .trip-tools { background: rgba(255,255,255,0.12); }
.trip-screen .trip-me .trip-tools .trip-ibtn { background: transparent; color: #fff; }
.trip-tools .ti { width: 18px; height: 18px; }
.trip-en { color: var(--muted); font-size: 0.82rem; line-height: 1.35; padding-bottom: 2px; }
.trip-badge { display: inline-flex; align-items: center; gap: 2px; margin: 0; font-size: 0.78rem; color: var(--faint); }
.trip-badge.ok { color: var(--ok); }
.trip-badge .ti { width: 14px; height: 14px; }
.trip-badge:not(.ok) .ti { width: 18px; height: 18px; }
.trip-tip { align-self: stretch; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px; padding: 10px 14px;
  border-radius: 16px; background: #fff6da; color: #5a4413; font-size: 0.9rem; line-height: 1.5; }
.trip-tip .ti { color: var(--gold); margin-top: 2px; }

.trip-dock { grid-area: dock; max-height: 48dvh; overflow-y: auto; padding: 14px 4px 8px; margin: 0 -4px; }
.trip-options { display: grid; gap: 10px; }
.trip-options-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trip-convo:not(.show-reply-en) :is(.trip-option-pick, .trip-say) .trip-option-en { display: none; }
.trip-screen .trip-reply-en { width: 36px; height: 32px; border-radius: 999px; background: var(--surface-3); color: var(--text); font-family: -apple-system, "Segoe UI", sans-serif; font-size: 0.72rem; font-weight: 800; }
.trip-screen .trip-reply-en[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
.trip-say-head > .trip-reply-en { position: absolute; left: auto; right: -4px; top: 6px; }
.trip-options-label { font-size: 0.95rem; font-weight: 750; letter-spacing: -0.01em; color: var(--text); margin: 4px 0 0; }
.trip-option { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; border-radius: var(--r);
  background: var(--surface); box-shadow: var(--shadow); transition: box-shadow 0.15s, background 0.15s; }
/* Hover/press: a soft tinted ring, drawn inside the card so a scrolling parent can never clip it. */
@media (hover: hover) { .trip-option:hover { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tint-ink) 35%, transparent), var(--shadow); } }
.trip-option:active { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tint-ink) 45%, transparent), var(--shadow); }
.trip-option-pick { display: flex; align-items: flex-start; gap: 10px; text-align: left; padding: 12px 58px 9px 16px;
  border: 0; background: none; border-radius: var(--r); min-width: 0; position: relative; }
.trip-option-pick .zh { font-size: 1.15rem; line-height: 1.95; }

.trip-option-text { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.trip-option-say { flex: none; display: grid; place-items: center; width: 40px; height: 40px; margin-top: 12px; border-radius: 50%; background: var(--ink); color: #fff; }
.trip-option-say .ti { width: 19px; height: 19px; }
.trip-option-en { color: var(--muted); font-size: 0.8rem; line-height: 1.3; }
.trip-practiced { display: inline-flex; align-items: center; gap: 1px; margin-top: 4px; color: var(--ok); font-size: 0.75rem; }
.trip-practiced .ti { width: 14px; height: 14px; }
.trip-screen .trip-option-hear { position: absolute; right: 12px; top: 50%; margin-top: -20px; width: 40px; height: 40px; background: var(--tint); color: var(--tint-ink); }
.trip-option-hear:hover:not(:disabled) { background: var(--tint); color: var(--text); }
.trip-own { margin-top: 12px; }
.trip-own-toggle { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 16px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text); font-size: 0.92rem; font-weight: 650; }
@media (hover: hover) { .trip-own-toggle:hover span { text-decoration: underline; text-underline-offset: 3px; } }
.trip-own-editor { margin-top: 4px; }
.trip-own-form { display: flex; align-items: flex-end; gap: 6px; margin-top: 6px; padding: 5px 5px 5px 14px; border-radius: var(--r);
  background: var(--surface); box-shadow: 0 0 0 2px var(--ink); }
.trip-own-form > .trip-ibtn:first-child { width: 36px; height: 36px; margin-left: -10px; }
.trip-own-form textarea { flex: 1; min-width: 0; min-height: 36px; max-height: 120px; padding: 8px 0; resize: none; border: 0; outline: 0;
  background: none; color: var(--text); font: inherit; font-size: max(1rem, 16px); field-sizing: content; }
.trip-own-form textarea::placeholder { color: var(--faint); }
.trip-screen .trip-send { background: var(--ink); color: var(--on-ink); width: 40px; height: 40px; }
.trip-send:hover:not(:disabled) { background: var(--ink); filter: brightness(1.25); color: var(--on-ink); }
.trip-own-status:not(:empty) { margin-top: 6px; }
.trip-own-result { margin-top: 10px; padding: 8px 16px 12px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.trip-own-result .trip-tools { margin-top: 6px; gap: 8px; }

.trip-say { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; justify-content: flex-start;
  padding: 12px 16px 18px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.trip-say-head { position: relative; align-self: stretch; display: flex; align-items: center; justify-content: center; min-height: 44px; }
.trip-say-head > .trip-ibtn:not(.trip-reply-en) { position: absolute; left: -12px; top: 0; }
.trip-say-head .trip-say-label { line-height: 1; }
.trip-say-face { display: block; flex: none; margin: 4px 0 8px; width: 76px; height: 76px; border-radius: 50%; overflow: hidden; background: var(--tint); box-shadow: 0 0 0 4px var(--tint); }
.trip-say-face img { width: 100%; height: 100%; object-fit: cover; }
.trip-say-face img.is-cutout { height: 140%; object-position: center 6%; }
.trip-say-label { font-size: 0.95rem; font-weight: 750; letter-spacing: -0.01em; color: var(--text); }
.trip-say .zh.trip-say-line { font-size: 1.55rem; line-height: 2.1; text-wrap: balance; }
.trip-say-line .missed { color: var(--warn); text-decoration: underline wavy; text-underline-offset: 5px; }
.trip-say-controls { display: flex; align-items: center; gap: 24px; margin: 18px 0 6px; }
.trip-screen .trip-say-controls > .trip-ibtn { width: 52px; height: 52px; background: var(--surface-3); color: var(--text); }
.trip-screen .trip-mic { width: 80px; height: 80px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; display: grid; place-items: center;
  box-shadow: 0 4px 12px rgb(29 26 38 / 12%), 0 0 0 8px var(--tint); transition: transform 0.15s, background 0.15s; }
.trip-screen .trip-mic.listening { background: var(--mic); }
.trip-mic:active { transform: scale(0.96); }
.trip-mic .ti { width: 30px; height: 30px; }
.trip-mic.listening { animation: trip-pulse 1.3s ease-in-out infinite; }
@keyframes trip-pulse { 50% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--mic) 22%, transparent); } }
@media (prefers-reduced-motion: reduce) { .trip-mic.listening { animation: none; outline: 3px solid var(--mic); outline-offset: 4px; } .trip-progress span { transition: none; } .trip-log { scroll-behavior: auto; } .trip-words-panel { animation: none; } .trip-char [data-trip-word] { transition: none; } }
.trip-heard { color: var(--muted); font-size: 0.92rem; }
.trip-heard:empty, .trip-verdict:empty { display: none; }
.trip-verdict { font-weight: 700; min-height: 1.4em; display: inline-flex; align-items: center; gap: 2px; font-size: 0.95rem; }
.trip-verdict.ok { color: var(--ok); }
.trip-verdict:not(.ok) { color: var(--warn); font-weight: 500; }
.trip-continue { min-width: min(280px, 90%); margin: 8px 0 2px; }
.trip-say > .trip-go { margin-top: 8px; }

.trip-end { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); }
.trip-end h2 { display: flex; align-items: center; gap: 8px; font-size: 1.35rem; color: var(--ok); }
.trip-end h2 .ti { width: 24px; height: 24px; }
.trip-end-list { display: grid; gap: 6px; }
.trip-end-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 4px 12px; border-radius: 14px; background: var(--surface-2); }
.trip-end-list .zh { font-size: 1.1rem; line-height: 1.9; }
.trip-end-list .py { display: none; }
.trip-end-count { color: var(--muted); font-size: 0.85rem; }
.trip-end-list li.is-mastered .trip-end-count { color: var(--ok); }
.trip-end-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.trip-end { animation: trip-end-pop 520ms cubic-bezier(.2,1.4,.4,1) both; }
@keyframes trip-end-pop { from { opacity: 0; transform: translateY(12px) scale(0.94); } }
.trip-end-cheer { margin-top: -6px; font-size: 1.05rem; font-weight: 600; color: var(--tint-ink); }
.trip-confetti { position: fixed; inset: 0; z-index: 60; overflow: hidden; pointer-events: none; }
.trip-confetti.is-inside { position: absolute; z-index: 0; border-radius: inherit; }
.trip-confetti.is-done { z-index: 2; }
.trip-confetti i { position: absolute; top: 0; left: 0; display: block; border-radius: 2px; will-change: transform; }
@media (prefers-reduced-motion: reduce) { .trip-end { animation: none; } }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  .trip-screen { padding: max(10px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); }
  .trip-home .trip-bar { min-height: 76px; margin: 0 4px 16px; }
  .trip-home .trip-bar-title p { display: block; }
  .trip-overview { padding: 16px; border-radius: 22px; }
  .trip-overview-row { grid-template-columns: minmax(84px, 1fr) auto; gap: 7px; }

  .trip-convo { display: block; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; }
  .trip-convo .trip-bar { position: sticky; top: calc(0px - max(10px, env(safe-area-inset-top))); z-index: 8;
    min-height: 60px; margin: calc(0px - max(10px, env(safe-area-inset-top))) -16px 10px; padding: max(10px, env(safe-area-inset-top)) 16px 10px;
    background: var(--bg); box-shadow: 0 1px 0 var(--line); }
  .trip-convo .trip-bar::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 18px; background: linear-gradient(var(--bg), transparent); pointer-events: none; }
  .trip-convo .trip-bar-title p { display: none; }
  .trip-convo .trip-bar-title h1 { font-size: 0.92rem; line-height: 1.25; letter-spacing: -0.02em; }
  .trip-convo .trip-bar { --tap: 38px; gap: 10px; }
  .trip-convo .trip-bar-tools { gap: 4px; }
  .trip-words-panel { top: auto; right: 0; bottom: 0; left: 0; width: 100%; max-height: min(82dvh, 720px);
    padding: 8px 16px max(16px, env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0;
    animation-name: trip-sheet-in; }
  @keyframes trip-sheet-in { from { opacity: 0; transform: translateY(24px); } }
  .trip-words-head { top: -8px; margin: 0 -2px; padding-top: 14px; border-radius: 26px 26px 0 0; }
  .trip-stage { min-height: 0; display: flex; }
  .trip-history-toggle { margin: 0 0 6px; }
  .trip-log { flex: none; min-height: 0; overflow: visible; gap: 10px; padding: 0 0 10px; }
  .trip-log:not(.show-all) .is-earlier { display: none; }
  .trip-char { max-width: 100%; align-self: stretch; }
  .trip-me { max-width: 88%; }
  .trip-char, .trip-say, .trip-tip { scroll-margin-top: 92px; }
  .trip-screen .zh { font-size: 1.12rem; line-height: 1.92; }
  .trip-option-pick .zh { font-size: 1.04rem; }
  .trip-dock { max-height: none; overflow: visible; margin: 0; padding: 14px 0 max(12px, env(safe-area-inset-bottom)); }
  .trip-convo.is-saying::after { content: ""; position: fixed; z-index: 29; inset: 0; background: rgba(38, 26, 18, 0.4); }
  .trip-convo.is-saying .trip-dock { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; max-height: 90dvh; overflow-y: auto;
    padding: 6px 16px max(18px, env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; background: var(--bg);
    box-shadow: 0 -5px 20px rgb(29 26 38 / 10%); animation: trip-sheet-in 0.22s ease-out; }
  .trip-convo.is-saying .trip-say { background: transparent; box-shadow: none; border-radius: 0; padding: 14px 8px 0; }
  .trip-convo.is-saying .trip-dock { padding-left: 24px; padding-right: 24px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .trip-convo.is-saying .trip-dock::before { content: ""; display: block; width: 40px; height: 5px; margin: 4px auto 0; border-radius: 999px; background: #d6ccbd; }
  .trip-say .zh.trip-say-line { font-size: 1.4rem; }
  .trip-say-controls { gap: 22px; }
  .trip-mic { width: 76px; height: 76px; }
  .trip-end-actions { align-items: stretch; flex-direction: column-reverse; }
  .trip-end-actions .trip-go { width: 100%; }
}

@media (max-width: 360px) {
  .trip-screen { padding-right: 12px; padding-left: 12px; }
  .trip-overview { padding: 12px; }
  .trip-overview-row { grid-template-columns: minmax(96px, 1fr) auto; }
  .trip-overview-label strong { font-size: 0.75rem; }
  .trip-overview-dots { gap: 4px; }
  .trip-dot { width: 13px; height: 13px; min-width: 13px; }
  .trip-row { grid-template-columns: 48px minmax(0, 1fr) auto; gap: 9px; }
  .trip-row-face { width: 48px; height: 48px; }
  .trip-tag { font-size: 0.74rem; padding: 0 8px; }
  .trip-hero { grid-template-columns: minmax(0, 1fr) 96px; }
  .trip-char, .trip-me { max-width: 98%; }
}

.trip-sttlog { max-height: 9.5em; margin: 6px 0 0; padding: 6px 8px; overflow: auto; border-radius: 10px; background: var(--surface-2); color: var(--muted); font: 11px/1.35 ui-monospace, Menlo, monospace; white-space: pre-wrap; }

/* ---- Done: a full-screen celebration when a conversation is finished ---- */
.trip-done { --sun: #ffd84d; --sun-soft: #fff0b8; --paper: #fff8e6; --warm: #7a5a00; --card-shadow: 0 1px 2px rgb(59 42 0 / 4%), 0 3px 10px rgb(59 42 0 / 4%);
  position: fixed; inset: 0; z-index: 55; display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); color: var(--ink); animation: trip-done-in 420ms cubic-bezier(.2,.9,.3,1.15) both; }
.trip-done:focus { outline: none; }
@keyframes trip-done-in { from { opacity: 0; transform: translateY(28px) scale(0.97); } }
.trip-done-sheet { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 460px; margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }
.trip-done-exits { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.trip-done-exits .trip-done-pill { justify-content: center; min-height: 48px; font-size: 0.95rem; }
.trip-done-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px 0 12px; border: 0; border-radius: 999px;
  background: #fff; color: var(--ink); font: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer; box-shadow: var(--card-shadow); }
.trip-done-pill .ti { width: 18px; height: 18px; }
.trip-done-pill:active, .trip-done-again:active { transform: scale(0.96); }
.trip-done-hero { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; margin-top: 72px;
  padding: 0 20px 20px; border-radius: 28px; background: var(--sun); color: var(--ink); }
.trip-done-hero-bg { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 55%); }
.trip-done-hero-bg::before { content: ""; position: absolute; left: 50%; top: 10%; width: 900px; height: 900px; margin: -450px 0 0 -450px;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.16) 0deg 9deg, rgba(255, 255, 255, 0) 9deg 22.5deg);
  -webkit-mask-image: radial-gradient(circle, #000 0, #000 12%, transparent 30%); mask-image: radial-gradient(circle, #000 0, #000 12%, transparent 30%);
  animation: trip-rays 40s linear infinite; }
@keyframes trip-rays { to { rotate: 360deg; } }
.trip-done-hero > :not(.trip-done-hero-bg) { position: relative; z-index: 1; }
.trip-done-wave { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 18%; color: rgba(255, 255, 255, 0.24); }
.trip-done-sparkle { position: absolute; width: var(--z, 16px); height: var(--z, 16px); color: #fff; filter: drop-shadow(0 1px 1px rgba(122, 90, 0, 0.35)); pointer-events: none; animation: trip-twinkle 2.2s ease-in-out infinite; }
.trip-done-sparkle.s1 { top: 22px; left: 22px; --z: 26px; }
.trip-done-sparkle.s2 { bottom: 22px; left: 24px; --z: 16px; animation-delay: .7s; }
.trip-done-sparkle.s3 { bottom: 26px; right: 24px; --z: 26px; animation-delay: 1.4s; }
.trip-done-sparkle.s4 { top: 64px; left: 60px; --z: 16px; animation-delay: 2s; }
@keyframes trip-twinkle { 50% { opacity: 0.5; scale: 0.8; } }
.trip-done-bit { position: absolute; width: 10px; height: 5px; border-radius: 2px; pointer-events: none; }
.trip-done-bit.b1 { top: 150px; left: 18px; background: #ff7a59; rotate: 28deg; }
.trip-done-bit.b2 { top: 22px; right: 22%; background: #2d7355; rotate: -18deg; }
.trip-done-bit.b3 { top: 58px; left: 70px; background: #2d7355; rotate: 52deg; }
.trip-done-bit.b4 { top: 214px; left: 22px; width: 7px; height: 7px; border-radius: 50%; background: #2d7355; }
.trip-done-bit.b5 { top: 64px; right: 16px; width: 7px; height: 7px; border-radius: 50%; background: #ff7a59; }
.trip-done-bit.b6 { top: 240px; right: 22px; background: #2d7355; rotate: -34deg; }
.trip-done-bit.b7 { top: 150px; right: 64px; background: #fff; rotate: 12deg; }
.trip-done-bit.b8 { top: 150px; left: 22px; width: 6px; height: 6px; border-radius: 50%; background: #fff; }
.trip-done-bit.b9 { top: 200px; right: 7%; background: #ff7a59; rotate: 70deg; opacity: .8; }
.trip-done-stage { display: grid; place-items: center; width: 100%; height: 140px; margin: -58px 0 4px; }
.trip-done-face { position: relative; grid-area: 1 / 1; display: block; width: 140px; height: 140px; border-radius: 50%; border: 5px solid #fff;
  background: #fff; box-shadow: 0 5px 14px rgb(59 42 0 / 11%); animation: trip-face-pop 640ms 120ms cubic-bezier(.2,1.6,.4,1) both; }
.trip-done-face img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.trip-done-face.is-small { width: 52px; height: 52px; border-width: 3px; align-self: end; animation-delay: 300ms; }
.trip-done-face.is-left { justify-self: center; transform: translateX(-92px); }
.trip-done-face.is-right { justify-self: center; transform: translateX(92px); }
@keyframes trip-face-pop { from { scale: 0.4; rotate: -12deg; opacity: 0; } }
.trip-done-medal { position: absolute; right: 0; bottom: 8px; display: grid; place-items: center; width: 31px; height: 31px;
  border-radius: 50%; border: 3px solid #fff; background: var(--ok); color: #fff; animation: trip-face-pop 520ms 560ms cubic-bezier(.2,1.8,.4,1) both; }
.trip-done-medal .ti { width: 16px; height: 16px; }
.trip-done-bubble { grid-area: 1 / 1; align-self: center; justify-self: center; transform: translate(116px, 66px); position: relative;
  display: flex; flex-direction: column; align-items: flex-start; padding: 6px 12px 7px; border-radius: 16px; background: #fff; color: var(--ink);
  font-size: 1rem; font-weight: 800; line-height: 1.2; white-space: nowrap; box-shadow: 0 3px 8px rgb(59 42 0 / 10%);
  animation: trip-bubble-in 480ms 820ms cubic-bezier(.2,1.6,.4,1) both; }
.trip-done-bubble::after { content: ""; position: absolute; left: -6px; top: 10px; width: 14px; height: 14px; border-radius: 0 0 0 4px;
  background: #fff; transform: rotate(45deg); }
.trip-done-bubble small { color: rgba(29, 26, 38, 0.62); font-size: 0.7rem; font-weight: 700; }
@keyframes trip-bubble-in { from { opacity: 0; scale: 0.5; } }
.trip-done-cheer { margin: 0; font-size: 3.1rem; line-height: 1.1; font-weight: 900; letter-spacing: 0.02em; }
.trip-done-eyebrow { margin: 12px 0 2px; padding: 2px 12px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1.5px #e0a800; color: #3b2c00; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.04em; }
.trip-done-cheer-py { margin: 6px 0 0; color: var(--ink); font-size: 1rem; font-weight: 700; }
.trip-done-cheer-en { margin: 0; color: #4a3f10; font-size: 0.9rem; font-weight: 500; }
.trip-done-cheer-en { margin: 0 0 14px; color: var(--ink); font-size: 0.95rem; font-weight: 500; opacity: 0.72; }
.trip-done-title-zh { display: inline-block; margin-right: 8px; padding: 2px 10px; border-radius: 999px; background: #fff; color: var(--ink); font-size: 0.9rem; font-weight: 700; }
.trip-done-title-en { display: inline-block; }
.trip-done-title { margin: 0; max-width: 32ch; color: rgba(29, 26, 38, 0.78); font-size: 0.95rem; line-height: 1.7; font-weight: 500; text-wrap: balance; }
.trip-done-badge { margin-top: 10px; padding: 3px 10px; border-radius: 999px; background: var(--ink); color: var(--sun); font-size: 0.75rem; font-weight: 800; }
.trip-done-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.trip-done-stat { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 18px 6px 12px; border-radius: 24px; background: #fff; color: var(--ink);
  text-align: center; border: 1px solid rgba(59, 42, 0, 0.08); box-shadow: 0 1px 0 rgba(59, 42, 0, 0.05); animation: trip-done-rise 480ms cubic-bezier(.2,1.2,.4,1) both; }
.trip-done-stat:nth-child(2) { animation-delay: 90ms; } .trip-done-stat:nth-child(3) { animation-delay: 180ms; }
@keyframes trip-done-rise { from { opacity: 0; transform: translateY(14px); } }
.trip-done-stat-icon { display: grid; place-items: center; width: 34px; height: 34px; margin-bottom: 6px; border-radius: 50%; }

.trip-done-stat-icon { background: var(--sun-soft); color: #6b4a00; }
.trip-screen .trip-done-reward { position: absolute; top: -9px; right: 8px; padding: 2px 8px; border-radius: 999px; background: var(--ok); color: #fff; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.02em;
  animation: trip-face-pop 520ms 900ms cubic-bezier(.2,1.8,.4,1) both; }

.trip-done-stat-icon .ti { width: 20px; height: 20px; }
.trip-done-stat b { font-size: 1.35rem; line-height: 1.1; font-weight: 900; letter-spacing: -0.01em; }
.trip-screen .trip-done-stat .trip-done-stat-label { font-size: 0.82rem; font-weight: 500; color: rgba(29, 26, 38, 0.72); white-space: nowrap; }
.trip-done-trip { display: grid; gap: 10px; padding: 14px 18px; border-radius: 24px; background: #fff; border: 1px solid rgba(59, 42, 0, 0.08); box-shadow: 0 1px 0 rgba(59, 42, 0, 0.05); }
.trip-done-trip-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 0.95rem; }
.trip-done-trip-where b { font-weight: 800; }
.trip-screen .trip-done-trip-where .han { color: var(--muted); font-size: 0.85rem; }
.trip-done-trip-count { font-weight: 800; white-space: nowrap; }
.trip-done-steps { display: flex; gap: 6px; }
.trip-done-steps i { flex: 1; height: 14px; border-radius: 999px; background: #f1e7cc; }
.trip-done-steps i.on { background: var(--ok); }
.trip-done-steps i.is-new { background: #f5b800; }
.trip-screen .trip-done-trip-all { margin: 0; color: #6b6358; font-size: 0.8rem; font-weight: 600; }
.trip-done-h3 { margin: 4px 2px -6px; font-size: 1.1rem; font-weight: 800; }
.trip-done-phrases { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.trip-done-phrase { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px;
  border-radius: 24px; background: #fff; border: 1px solid rgba(59, 42, 0, 0.08); box-shadow: 0 1px 0 rgba(59, 42, 0, 0.05);
  animation: trip-done-rise 480ms cubic-bezier(.2,1.2,.4,1) both; }
.trip-done-phrase:nth-child(2) { animation-delay: 60ms; } .trip-done-phrase:nth-child(3) { animation-delay: 120ms; }
.trip-done-phrase:nth-child(4) { animation-delay: 180ms; } .trip-done-phrase:nth-child(5) { animation-delay: 240ms; }
.trip-done-phrase.is-learned { background: #e3f6ea; border-color: transparent; } .trip-done-phrase.is-started { background: #fff6d1; border-color: transparent; }
.trip-done-phrase.is-todo { background: transparent; border: 1.5px dashed #d9c9a3; box-shadow: none; }
.trip-screen .trip-done-phrase.is-todo .trip-done-phrase-en, .trip-screen .trip-done-phrase.is-todo .py { color: #6b6358; }
.trip-screen .trip-done-phrase.is-todo .trip-done-phrase-tag { color: rgba(29, 26, 38, 0.6); font-weight: 700; }
.trip-done-phrase.is-todo .trip-done-pips { opacity: 0.55; }
.trip-done-phrase-copy { min-width: 0; }
.trip-done-phrase .zh { margin: 0; font-size: 1.3rem; line-height: 1.3; font-weight: 800; letter-spacing: 0.02em; }
.trip-screen .trip-done-phrase .py { display: block; margin: 1px 0; color: rgba(29, 26, 38, 0.62); font-size: 0.8rem; font-weight: 700; line-height: 1.3; }
.trip-screen .trip-done-phrase-en { display: block; font-size: 0.85rem; line-height: 1.3; color: var(--muted); }
.trip-done-phrase-state { display: flex; flex: none; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-width: 64px; }
.trip-done-pips { display: flex; gap: 6px; }
.trip-done-pips i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(29, 26, 38, 0.4); }
.trip-done-pips i.on { border-color: var(--ok); background: var(--ok); }
.trip-screen .trip-done-phrase-tag { font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.trip-done-phrase.is-learned .trip-done-phrase-tag { color: var(--ok); }
.trip-done-foot { position: sticky; bottom: max(14px, calc(env(safe-area-inset-bottom) + 6px)); z-index: 4; margin-top: 2px; }
.trip-done-next { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; min-height: 66px; padding: 10px 24px;
  border: 0; border-radius: 999px; background: #2a2118; color: #fff; text-align: left; cursor: pointer;
  box-shadow: 0 4px 12px rgb(42 33 24 / 12%); animation: trip-done-rise 520ms 300ms cubic-bezier(.2,1.2,.4,1) both; }
.trip-done-next:active { transform: scale(0.97); }
.trip-done-next-copy { display: flex; flex-direction: column; min-width: 0; }
.trip-screen .trip-done-next-kicker { color: var(--sun); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.trip-screen .trip-done-next-title { color: #fff; font-size: 1.05rem; line-height: 1.3; font-weight: 700; }
.trip-done-next-arrow { display: grid; flex: none; place-items: center; width: 50px; height: 50px; border-radius: 50%; background: var(--sun); color: var(--ink); }
.trip-done-next > .ti { flex: none; width: 24px; height: 24px; color: var(--sun); }
.trip-done :is(button):focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.trip-convo.is-done { overflow: hidden; }
@media (min-width: 761px) {
  .trip-done { background: rgba(29, 26, 38, 0.35); }
  .trip-done-sheet { margin: 24px auto; border-radius: 36px; background: var(--paper); padding-top: 16px; padding-bottom: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .trip-done, .trip-done-face, .trip-done-medal, .trip-done-bubble, .trip-done-stat, .trip-done-phrase, .trip-done-sparkle, .trip-done-next, .trip-done-steps i, .trip-done-hero-bg::before, .trip-done-reward { animation: none; }
}

/* Standalone practice home. The paintings are scenery. All controls are HTML. */
.trip-practice-stack {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  isolation: isolate;
  height: 100%;
  overflow: clip;
}
.trip-practice-stack > .trip-screen { grid-area: 1 / 1; min-height: 0; }
.trip-practice-stack > .trip-library { box-shadow: -10px 0 30px rgb(29 26 38 / 16%); }

.trip-screen.trip-practice-home {
  flex: 1;
  min-height: 0;
  padding: 0;
  overflow: clip;
}
.practice-home {
  position: relative;
  isolation: isolate;
  container: practice-home / size;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: min(100%, var(--practice-viewport, 100dvh));
  padding: max(12px, env(safe-area-inset-top)) clamp(12px, 4vw, 24px) max(18px, env(safe-area-inset-bottom));
  background: #203a32;
  overflow: clip;
}
.practice-home:focus { outline: none; }
.practice-home-nav { justify-self: end; }
.practice-home .practice-set-button {
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 999px;
  background: rgb(32 35 37 / 96%);
  color: #f5f5f3;
  font-size: .86rem;
  font-weight: 650;
  transition: background-color 160ms ease, transform 160ms ease;
}
.practice-home .practice-set-button:hover { background: #393b3d; }
.practice-home .practice-set-button:active { transform: scale(.96); }
.practice-home .practice-set-button:focus-visible { outline-color: #f5f5f3; }
.trip-bar-tools .trip-magic-back { color: var(--blue); background: var(--gold-soft); }
.trip-bar-tools .trip-magic-back:hover { background: var(--tint); color: var(--text); }
.trip-library h1:focus { outline: none; }
.practice-painting {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
}
.practice-panel {
  --card: #232426; --fill-on: #36373a; --fill-slab: #222325;
  --ink: #f5f5f3; --muted: #bec0c3; --pane-edge: #494b4f; --signal: #bfc9ff;
  --incoming-bubble: 18px 18px 18px 6px;
  --outgoing-bubble: 18px 18px 6px 18px;
  color-scheme: dark;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  width: min(100%, 340px);
  min-width: 0;
  margin-inline: auto;
  align-self: end;
  font: 400 1rem/1.4 system-ui, sans-serif;
  color: var(--ink);
}
.practice-panel[data-theme="light"] {
  --card: #fbfbf8; --fill-on: #e7ebe5; --fill-slab: #fbfbf8;
  --ink: #202825; --muted: #4a5550; --pane-edge: #c2ccc4; --signal: #2b694a;
  color-scheme: light;
}
.practice-panel h2 { font-size: 1.24rem; font-weight: 650; }
.practice-suggestions {
  display: grid;
  justify-items: start;
  gap: 7px;
  margin-bottom: 11px;
}
.practice-panel .practice-topic {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--pane-edge);
  border-radius: var(--incoming-bubble);
  background: var(--fill-slab);
  color: var(--ink);
  text-align: left;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -.01em;
  transition: background-color 160ms ease;
}
.practice-panel .practice-topic:hover { background: var(--fill-on); }
.practice-panel .practice-topic:focus-visible { outline-color: var(--signal); }
.practice-form {
  position: relative;
  display: flex;
  align-items: center;
  gap: 3px;
  width: min(100%, 240px);
  height: 48px;
  margin-inline: auto;
  padding: 3px 5px 3px 16px;
  border: 1px solid var(--pane-edge);
  border-radius: 24px;
  background: var(--fill-slab);
  transition: width 420ms cubic-bezier(.24, 1.34, .38, 1), height 420ms cubic-bezier(.24, 1.34, .38, 1);
}
.practice-form > input {
  flex: 1;
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: inherit;
  font: 400 16px/1.2 system-ui, sans-serif;
}
.practice-form > input::placeholder { color: var(--muted); opacity: 1; }
.practice-panel .practice-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  font-size: 1.2rem;
  background: var(--ink);
  color: var(--card);
}
.practice-panel .practice-send:disabled { background: var(--fill-on); color: var(--muted); opacity: 1; }
.practice-select { display: grid; gap: 2px; min-width: 0; font: 650 .72rem/1.2 system-ui; color: var(--muted); }
/* The assistant uses the same soft surface and rounded options as the script picker. */
.practice-choice { position: relative; min-width: 0; }
.practice-panel .practice-choice-trigger {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 40px;
  padding: 0 17px;
  border: 0;
  border-radius: 999px;
  background: var(--fill-on);
  color: var(--ink);
  font-size: .8rem;
  font-weight: 650;
  list-style: none;
  cursor: pointer;
}
.practice-choice-trigger::after {
  content: "";
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 1.5px 1.5px 0 0;
  transform: rotate(-45deg) translateY(2px);
  transition: transform 220ms cubic-bezier(.22, .76, .24, 1);
}
.practice-choice.is-open > .practice-choice-trigger::after { transform: rotate(135deg) translateY(2px); }
.practice-choice.is-open > .practice-choice-trigger { box-shadow: inset 0 0 0 1px var(--pane-edge); }
.practice-choice-trigger:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.practice-panel .practice-choice-options {
  position: absolute;
  z-index: 5;
  left: 0;
  bottom: calc(100% + 7px);
  width: max-content;
  min-width: 156px;
  max-width: min(270px, calc(100vw - 68px));
  max-height: 12rem;
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--pane-edge);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 8px 22px rgb(12 30 20 / 18%);
  transform: translateY(7px) scale(.96);
  transform-origin: bottom left;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease, transform 220ms cubic-bezier(.22, .76, .24, 1), visibility 0s linear 220ms;
}
.practice-choice.is-open > .practice-choice-options {
  transform: none;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}
.practice-panel .practice-choice-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 7px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  font-size: .85rem;
}
.practice-panel .practice-choice-option:is(:hover, [aria-pressed="true"]) { background: var(--fill-on); }
.practice-choice-option[aria-pressed="true"]::after { content: "✓"; }
.practice-status { font-size: .84rem; margin-top: 8px; }
.practice-status:empty { display: none; }
.practice-panel .practice-text-button { min-height: 44px; border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; font-weight: 650; }
.practice-panel .practice-working {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  overflow: clip;
  justify-items: center;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 24px;
  background: var(--card);
  overflow-wrap: anywhere;
  text-align: center;
}
.practice-working p {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  overflow: hidden;
  width: fit-content;
  min-width: 0;
  max-width: 100%;
  padding: 10px 15px;
  text-wrap: balance;
  border-radius: var(--outgoing-bubble);
  background: var(--ink);
  color: var(--card);
  font-size: .95rem;
}
/* Bencho-style thinking state: a quiet outline, shaded rays, and a label
   that trades places vertically with the next one. */
.practice-thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--pane-edge);
  border-radius: 999px;
  color: var(--muted);
  font-size: .79rem;
  letter-spacing: -.01em;
}
.practice-thinking svg { flex: none; width: 15px; height: 15px; }
.practice-thinking line {
  stroke: var(--ink);
  stroke-width: 1.5;
  stroke-linecap: round;
  animation: practice-thinking-ray 800ms linear infinite;
}
.practice-thinking-slot {
  position: relative;
  display: block;
  height: 1.4em;
  min-width: 0;
  overflow: hidden;
  transition: width 360ms cubic-bezier(.22, 1, .36, 1);
}
.practice-thinking-label {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: practice-thinking-in 360ms cubic-bezier(.22, 1, .36, 1) both;
}
.practice-thinking-label.is-leaving { animation: practice-thinking-out 220ms ease both; }
.practice-thinking-label:not(.is-leaving)::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  color: transparent;
  background: linear-gradient(90deg, transparent 34%, var(--ink) 50%, transparent 66%) 100% 0 / 250% 100% no-repeat;
  background-clip: text;
  animation: practice-thinking-shine 1.8s linear infinite;
  pointer-events: none;
}
@keyframes practice-thinking-ray { to { stroke: var(--pane-edge); } }
@keyframes practice-thinking-in { from { opacity: 0; transform: translateY(12px); filter: blur(3px); } }
@keyframes practice-thinking-out { to { opacity: 0; transform: translateY(-10px); filter: blur(3px); } }
@keyframes practice-thinking-shine { to { background-position: 0 0; } }

/* The chat pill keeps one corner radius as it widens and grows on the spring curve. */
.practice-form[data-open] { display: block; width: 100%; height: 116px; }
.practice-form[data-open] .practice-send { position: absolute; right: 7px; bottom: 7px; }
.practice-input-tools {
  position: absolute;
  left: 8px;
  right: 53px;
  bottom: 8px;
  display: flex;
  align-items: center;
  opacity: 0;
  pointer-events: none;
}
.practice-form[data-open] .practice-input-tools {
  opacity: 1;
  pointer-events: auto;
  transition: opacity 180ms 140ms;
}
.practice-panel :is(.practice-status, .practice-text-button) {
  border-radius: 18px;
  background: var(--card);
  color: var(--ink);
  padding: 11px;
}

.practice-connection-actions { display: flex; justify-content: space-between; gap: 8px; }
.practice-panel .practice-primary {
  min-height: 44px; border: 0; border-radius: 12px; background: #295340; color: #fff;
  padding: 0 12px; font-weight: 700;
}
/* New generated talks open in place. Each glyph keeps its final layout
   position while the opener types, including its pinyin and punctuation. */
@media (prefers-reduced-motion: no-preference) {
  .trip-opening .trip-stage { animation: trip-open-stage 340ms cubic-bezier(.22, .76, .24, 1) both; }
  .trip-opening-wait :is(.trip-opening-character, .trip-char > .py, .trip-dock) { visibility: hidden; }
  .trip-opening-typing .trip-opening-character {
    animation: trip-type-character 1ms step-end var(--character-delay) both;
  }
  .trip-opening-typing .trip-char > .py {
    animation: trip-type-character 1ms step-end var(--opening-duration) both;
  }
  .trip-opening-typing .trip-dock {
    animation: trip-open-replies 200ms ease-out var(--opening-duration) both;
  }
}
@keyframes trip-open-stage {
  from { opacity: 0; transform: translateY(12px); }
}
@keyframes trip-type-character {
  from { visibility: hidden; }
  to { visibility: visible; }
}
@keyframes trip-open-replies {
  from { visibility: hidden; opacity: 0; transform: translateY(5px); }
  to { visibility: visible; opacity: 1; transform: none; }
}
.trip-recent { margin-bottom: 20px; }
.trip-recent h2, .trip-library-title { font-size: 1.18rem; }
.trip-library-title { margin-right: auto; }
@media (min-width: 760px) {
  .practice-painting { object-position: center 31%; }
}
@media (max-width: 360px) {
  .practice-home { padding-inline: 12px; }
  .practice-panel { padding-inline: 10px; }
}
@container practice-home (max-height: 440px) {
  .practice-suggestions { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
  .practice-panel .practice-topic { min-height: 30px; padding: 4px 8px; font-size: .75rem; }
  .practice-form[data-open] { height: 98px; }
  .practice-working p { -webkit-line-clamp: 3; }
}
@container practice-home (max-height: 255px) {
  .practice-suggestions { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .trip-convo:not(.trip-opening) .trip-stage {
    animation: trip-view-in 290ms cubic-bezier(.22, .76, .24, 1) both;
  }
  .practice-suggestions .practice-topic {
    animation: trip-slide-in 240ms cubic-bezier(.22, .76, .24, 1) both;
  }
  .practice-topic:nth-child(2) { animation-delay: 35ms; }
  .practice-topic:nth-child(3) { animation-delay: 70ms; }
  .trip-option { animation: trip-slide-in 260ms cubic-bezier(.22, .76, .24, 1) var(--reply-delay, 0ms) backwards; }
}
@keyframes trip-view-in { from { opacity: 0; } }
@keyframes trip-slide-in { from { opacity: 0; transform: translateY(7px); } }
@media (prefers-reduced-motion: reduce) {
  .practice-home * { animation: none !important; transition: none !important; }
  .practice-thinking-label::after { display: none; }
  .practice-thinking-label.is-leaving { display: none; }
}
.practice-connection {
  width: min(390px, calc(100% - 32px)); padding: 20px;
  border: 1px solid var(--pane-edge); border-radius: 18px; background: var(--card); color: var(--ink);
}
.practice-connection::backdrop { background: rgb(13 31 28 / 72%); }
.practice-connection p { margin-top: 5px; color: var(--muted); font-size: .86rem; }
.practice-connection form { display: grid; gap: 12px; margin-top: 14px; }
.practice-connection input {
  min-width: 0; min-height: 44px; padding: 6px 10px; border: 1px solid var(--pane-edge);
  border-radius: 9px; background: var(--fill-slab); color: var(--ink); font: 400 16px system-ui;
}
