/* ══════════════════════════════════════════════════════════════════════════
   v179 문장 번역 팝업 레이어 (sent-tr.css)
   앱의 CSS 변수(--card/--text/--text2/--border/--primary)만 쓰므로 다크모드 자동.
   ══════════════════════════════════════════════════════════════════════════ */

/* 활성 문장 하이라이트 (CSS Custom Highlight API) */
::highlight(sent-tr) {
  background-color: rgba(108, 140, 255, .30);
}

[data-theme="light"] ::highlight(sent-tr) {
  background-color: rgba(74, 108, 247, .20);
}

/* ── 팝업 ─────────────────────────────────────────────────────────────── */
.st-tr-pop {
  position: fixed;
  z-index: 9000;
  box-sizing: border-box;
  max-width: min(92vw, 440px);
  min-width: 180px;
  padding: .65rem .75rem .55rem;
  border: 1px solid var(--border, #ddd);
  border-radius: 12px;
  background: var(--card, #fff);
  color: var(--text, #111);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .08);
  font-size: .9rem;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-tap-highlight-color: transparent;
}

.st-tr-pop[hidden] { display: none !important; }

@media (prefers-reduced-motion: no-preference) {
  .st-tr-pop { animation: st-tr-in .12s ease-out both; }
  @keyframes st-tr-in {
    from { opacity: 0; transform: translateY(-3px) scale(.985); }
    to   { opacity: 1; transform: none; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .st-tr-pop { animation: none !important; }
}

/* 원문(작게, 최대 3줄) */
.st-tr-pop .st-tr-en {
  color: var(--text2, #666);
  font-size: .78rem;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: .15rem;
}

/* 번역(크게) */
.st-tr-pop .st-tr-ko {
  color: var(--text, #111);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: pre-wrap;
  margin-top: .2rem;
}

.st-tr-pop .st-tr-ko.st-tr-sent-ko {
  font-weight: 500;
  font-size: .9rem;
  color: var(--text2, #555);
  margin-top: .35rem;
  padding-top: .35rem;
  border-top: 1px dashed var(--border, #ddd);
}

.st-tr-pop .st-tr-muted { color: var(--text2, #888) !important; font-weight: 400; font-size: .84rem; }

/* 구문 메모 */
.st-tr-pop .st-tr-note {
  margin-top: .3rem;
  padding-top: .3rem;
  border-top: 1px dashed var(--border, #ddd);
  font-size: .78rem;
  line-height: 1.45;
  color: var(--text2, #666);
}

/* 단어 칩 */
.st-tr-pop .st-tr-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  margin-top: .4rem;
}
.st-tr-pop .st-tr-chip {
  border: 1px solid var(--border, #ddd);
  border-radius: 999px;
  padding: .08rem .45rem;
  font-size: .72rem;
  line-height: 1.5;
  color: var(--text2, #666);
  background: transparent;
}

/* 사전(표현 선택 시) */
.st-tr-pop .st-tr-dict {
  margin-top: .35rem;
  padding: .4rem .5rem;
  border-radius: 8px;
  background: rgba(108, 140, 255, .08);
  font-size: .84rem;
  line-height: 1.5;
}
.st-tr-pop .st-tr-dict b { color: var(--primary, #4a6cf7); }
.st-tr-pop .st-tr-pos { font-size: .72rem; color: var(--text2, #666); font-style: italic; margin-left: .2rem; }
.st-tr-pop .st-tr-ipa { font-size: .74rem; color: var(--text2, #777); margin-left: .2rem; }

/* 선택(여러 문장) 목록 */
.st-tr-pop .st-tr-head {
  font-size: .76rem;
  font-weight: 700;
  color: var(--text2, #666);
  margin-bottom: .25rem;
}
.st-tr-pop .st-tr-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 38vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.st-tr-pop .st-tr-list > li {
  padding: .35rem 0;
  border-bottom: 1px dashed var(--border, #ddd);
}
.st-tr-pop .st-tr-list > li:last-child { border-bottom: 0; }
.st-tr-pop .st-tr-en2 { font-size: .76rem; line-height: 1.4; color: var(--text2, #777); }
.st-tr-pop .st-tr-ko2 { font-size: .92rem; line-height: 1.45; font-weight: 600; color: var(--text, #111); margin-top: .1rem; }
.st-tr-pop .st-tr-aiko {
  margin-top: .4rem;
  padding-top: .4rem;
  border-top: 1px dashed var(--border, #ddd);
  font-size: .92rem;
  line-height: 1.5;
  font-weight: 600;
  white-space: pre-wrap;
}

/* 구문 분석 결과 */
.st-tr-pop .st-tr-ana {
  margin-top: .4rem;
  padding-top: .4rem;
  border-top: 1px dashed var(--border, #ddd);
  font-size: .8rem;
  line-height: 1.55;
  color: var(--text, #222);
  white-space: pre-wrap;
  max-height: 32vh;
  overflow-y: auto;
}

/* 버튼 줄 — 터치 타깃 44px */
.st-tr-pop .st-tr-acts {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .55rem;
  justify-content: flex-end;
}
.st-tr-pop .st-tr-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0 .7rem;
  border: 1px solid var(--border, #ddd);
  border-radius: 10px;
  background: transparent;
  color: var(--text, #111);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.st-tr-pop .st-tr-btn:hover,
.st-tr-pop .st-tr-btn:focus-visible {
  border-color: var(--primary, #4a6cf7);
  color: var(--primary, #4a6cf7);
  outline: none;
}
.st-tr-pop .st-tr-btn:active { transform: translateY(1px); }
.st-tr-pop .st-tr-x { font-size: .95rem; }
.st-tr-pop .st-tr-retry {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--primary, #4a6cf7);
  font: inherit;
  font-size: .84rem;
  font-weight: 600;
  padding: .5rem 0;
  min-height: 44px;
  cursor: pointer;
  text-align: left;
}

@media (prefers-reduced-motion: reduce) {
  .st-tr-pop .st-tr-btn { transition: none !important; }
  .st-tr-pop .st-tr-btn:active { transform: none; }
}

/* ── 토글 버튼 ────────────────────────────────────────────────────────── */
.st-tr-toggle {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 .7rem;
  border: 1px solid var(--border, #ddd);
  border-radius: 999px;
  background: transparent;
  color: var(--text2, #666);
  font: inherit;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.st-tr-toggle[aria-pressed="true"] {
  border-color: var(--primary, #4a6cf7);
  color: var(--primary, #4a6cf7);
  background: rgba(108, 140, 255, .10);
}
.st-tr-toggle:hover { border-color: var(--primary, #4a6cf7); color: var(--primary, #4a6cf7); }

/* 지문 도구줄 안에서는 폭을 조금 줄여 제목 자리를 지킨다 */
#ts-pass .ts-ptools .st-tr-toggle { flex: none; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }

/* 읽기 탭 — #rd-list 바로 위 */
.st-tr-toggle-wrap {
  display: flex;
  justify-content: flex-end;
  padding: .15rem 0 .3rem;
}

/* 344px 같은 좁은 화면에서 가로 스크롤이 생기지 않게 */
@media (max-width: 380px) {
  .st-tr-pop { max-width: calc(100vw - 16px); }
  .st-tr-pop .st-tr-btn { padding: 0 .55rem; font-size: .76rem; }
  #ts-pass .ts-ptools .st-tr-toggle { max-width: 44vw; font-size: .72rem; padding: 0 .5rem; }
}
