/* ---------- highlight-to-translate ---------- */
#app ::selection { background: rgba(var(--accent2-rgb), .38); color: #fff; }

.tr-pop {
  position: fixed; z-index: 400; width: min(360px, calc(100vw - 20px)); padding: 12px 14px 12px;
  background: rgba(var(--panel-rgb), .97); border: 1px solid rgba(var(--accent2-rgb), .35); border-radius: 14px;
  box-shadow: 0 24px 60px -18px rgba(var(--shadow-rgb), .95), 0 0 0 1px rgba(var(--shadow-rgb), .4);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  opacity: 0; transform: translateY(6px) scale(.98); pointer-events: none;
  transition: opacity .18s var(--ease), transform .22s var(--ease);
  font-size: 14px; color: var(--text);
}
.tr-pop.in { opacity: 1; transform: none; pointer-events: auto; }
.tr-pop::after { /* arrow */
  content: ''; position: absolute; left: var(--ax, 50%); bottom: -7px; width: 12px; height: 12px; margin-left: -6px;
  background: rgba(var(--panel-rgb), .97); border-right: 1px solid rgba(var(--accent2-rgb), .35); border-bottom: 1px solid rgba(var(--accent2-rgb), .35); transform: rotate(45deg);
}
.tr-pop.below::after { bottom: auto; top: -7px; transform: rotate(225deg); }
.tr-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tr-dir { display: inline-flex; align-items: center; gap: 4px; font: 500 var(--fs-xs)/1 var(--mono); letter-spacing: .1em; color: var(--text-3); }
.tr-dir i { width: 14px; height: 1px; background: var(--accent-2); position: relative; }
.tr-dir i::after { content: ''; position: absolute; right: -1px; top: -3px; border: 3.5px solid transparent; border-left-color: var(--accent-2); border-right: 0; }
.tr-seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--bg-elev); border: 1px solid var(--line); }
.tr-seg button { border: 0; background: none; color: var(--text-3); font: 600 var(--fs-xs)/1 var(--mono); letter-spacing: .08em; padding: 5px 7px; border-radius: 6px; cursor: pointer; }
.tr-seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.tr-x { border: 0; background: none; color: var(--text-3); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.tr-x:hover { color: var(--text); }
.tr-src { color: var(--text-3); font-size: 13px; line-height: 1.45; margin-bottom: 6px; }
.tr-out { font-family: var(--serif); font-size: 1.45rem; line-height: 1.2; color: var(--text); animation: trIn .35s var(--ease); }
.tr-out.loading { display: flex; gap: 8px; padding: 10px 0 6px; }
.tr-out.loading span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); animation: trDot 1s infinite ease-in-out; }
.tr-out.loading span:nth-child(2) { animation-delay: .15s; } .tr-out.loading span:nth-child(3) { animation-delay: .3s; }
@keyframes trDot { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }
@keyframes trIn { from { opacity: 0; transform: translateY(4px); } }
.tr-ctx { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--text-2); font-size: 13.5px; line-height: 1.45; }
.tr-ctx .tag { display: block; margin-bottom: 4px; color: var(--text-3); font-size: var(--fs-xs); }
.tr-err { color: var(--bad); font-size: 13.5px; padding: 6px 0; }
.tr-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.tr-badge { font: 500 var(--fs-xs)/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; padding: 5px 7px; border-radius: 6px; border: 1px solid var(--line-strong); color: var(--text-3); }
.tr-badge.lesson { color: var(--ok); border-color: rgba(var(--ok-rgb), .35); }
.tr-badge.ai { color: var(--accent-2); border-color: rgba(var(--accent2-rgb), .35); }
.tr-btn { border: 1px solid var(--line-strong); background: none; color: var(--text-2); font: 500 12px/1 var(--sans); padding: 6px 9px; border-radius: 7px; cursor: pointer; }
.tr-btn:hover { color: var(--text); border-color: rgba(var(--fg-rgb), .3); }

/* persistent pill */
.tr-pill {
  position: fixed; left: 16px; bottom: 16px; z-index: 80; display: flex; align-items: center; gap: 8px; padding: 5px;
  background: rgba(var(--panel-rgb), .92); border: 1px solid var(--line-strong); border-radius: 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 14px 40px -16px rgba(var(--shadow-rgb), .9);
  animation: trPillIn .5s var(--ease) both;
}
@keyframes trPillIn { from { opacity: 0; transform: translateY(12px); } }
.tr-pill-main { display: flex; align-items: center; gap: 8px; border: 0; background: none; color: var(--text); cursor: pointer; padding: 4px 8px 4px 4px; border-radius: 10px; text-align: left; }
.tr-pill-main:hover { background: rgba(var(--fg-rgb), .05); }
.tr-pill-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(var(--accent2-rgb), .14); color: var(--accent-2); position: relative; }
.tr-pill-ico svg { width: 18px; height: 18px; }
.tr-pill-main[aria-pressed="true"] .tr-pill-ico::after { content: ''; position: absolute; right: -2px; top: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2px var(--surface); }
.tr-pill-main[aria-pressed="false"] .tr-pill-ico { background: var(--surface-3); color: var(--text-3); }
.tr-pill-txt b { display: block; font: 600 12.5px/1.2 var(--sans); }
.tr-pill-txt small { display: block; font: 500 var(--fs-xs)/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin-top: 2px; }
.tr-pill-help { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line-strong); background: none; color: var(--text-3); font: 600 12px/1 var(--sans); cursor: pointer; }
.tr-pill-help:hover { color: var(--text); }
@media (max-width: 880px) { .tr-pill { bottom: calc(76px + env(safe-area-inset-bottom)); left: 10px; } .tr-pill-txt small { display: none; } }

/* first-run coach mark */
.tr-coach {
  position: fixed; z-index: 300; left: 50%; bottom: 28px; width: min(640px, calc(100vw - 24px)); transform: translate(-50%, 24px); opacity: 0;
  display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: center; padding: 18px 44px 18px 18px;
  background: rgba(var(--panel-rgb), .97); border: 1px solid rgba(var(--accent2-rgb), .4); border-radius: 18px;
  box-shadow: 0 30px 80px -24px rgba(var(--shadow-rgb), .95), 0 0 60px -20px rgba(var(--accent-rgb), .35);
  transition: opacity .4s var(--ease), transform .5s var(--ease);
}
.tr-coach.in { opacity: 1; transform: translate(-50%, 0); }
.tr-coach > .tr-x { position: absolute; right: 12px; top: 10px; }
.tr-coach h3 { font-size: 1.6rem; margin: 8px 0 6px; }
.tr-coach p { color: var(--text-2); font-size: 14px; line-height: 1.55; margin-bottom: 12px; }
.tr-coach .row { gap: 12px; }
@media (max-width: 880px) { .tr-coach { grid-template-columns: 1fr; bottom: calc(84px + env(safe-area-inset-bottom)); padding: 16px 40px 16px 16px; } .tr-demo { height: 112px; } }
.tr-demo { position: relative; height: 128px; border-radius: 12px; background: var(--bg-elev); border: 1px solid var(--line); overflow: hidden; padding: 64px 14px 0; }
.tr-demo p { font-size: 13.5px; color: var(--text); margin: 0; white-space: nowrap; }
.tr-demo-sel { background: linear-gradient(rgba(var(--accent2-rgb), .45), rgba(var(--accent2-rgb), .45)) no-repeat 0 0 / 0% 100%; animation: trSweep 4.2s var(--ease) infinite; padding: 1px 0; }
@keyframes trSweep { 0%, 12% { background-size: 0% 100%; } 38%, 88% { background-size: 100% 100%; } 100% { background-size: 0% 100%; } }
.tr-demo-pop { position: absolute; left: 12px; top: 12px; padding: 7px 10px; border-radius: 9px; background: var(--surface-3); border: 1px solid rgba(var(--accent2-rgb), .45); font: 400 1.05rem/1 var(--serif); display: flex; align-items: center; gap: 8px; white-space: nowrap; animation: trPop 4.2s var(--ease) infinite; }
@keyframes trPop { 0%, 40% { opacity: 0; transform: translateY(6px) scale(.96); } 48%, 86% { opacity: 1; transform: none; } 96%, 100% { opacity: 0; } }
.tr-demo-cursor { position: absolute; width: 18px; height: 18px; left: 12px; top: 80px; animation: trCursor 4.2s var(--ease) infinite; }
@keyframes trCursor { 0%, 10% { transform: translate(0, 0); } 38%, 88% { transform: translate(122px, 0); } 100% { transform: translate(0, 0); } }

/* landing demo */
.tr-try { border: 1px dashed rgba(var(--accent2-rgb), .45); border-radius: var(--r); padding: 22px 24px; background: rgba(var(--accent2-rgb), .04); }
.tr-try p.big { font-family: var(--serif); font-size: clamp(1.5rem, 3vw, 2.1rem); line-height: 1.3; margin: 10px 0 0; cursor: text; }

@media (prefers-reduced-motion: reduce) {
  .tr-demo-sel { background-size: 100% 100% !important; animation: none; }
  .tr-demo-pop { opacity: 1; animation: none; }
  .tr-demo-cursor { display: none; }
}
@media print { .tr-pop, .tr-pill, .tr-coach { display: none !important; } }

/* Quiet by default: the pill is just its icon until you point at it (or focus it). */
@media (hover: hover) {
  .tr-pill:not(:hover):not(:focus-within) { padding: 4px; gap: 0; box-shadow: 0 10px 30px -18px rgba(var(--shadow-rgb), .8); }
  .tr-pill:not(:hover):not(:focus-within) > :not(.tr-pill-main), .tr-pill:not(:hover):not(:focus-within) .tr-pill-txt { display: none; }
  .tr-pill:not(:hover):not(:focus-within) .tr-pill-main { padding: 2px; }
}
@media (hover: none) { .tr-pill-txt { display: none; } .tr-pill-main { padding: 2px; } }
