/* "Try it in your browser": the live quick-paste panel (try.js). Uses the page's tokens. */

:root {
  --tr-spring: cubic-bezier(0.22, 1.25, 0.36, 1);
  --tr-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --tr-panel: #FBF9F3;
  --tr-row-sel: #DCEBDD;
  --tr-shadow: 0 40px 90px -30px rgba(10, 30, 20, 0.55), 0 0 0 1px rgba(20, 36, 27, 0.10);
}
@media (prefers-color-scheme: dark) {
  :root {
    --tr-panel: #18231C;
    --tr-row-sel: #1E3B2B;
    --tr-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(232, 240, 234, 0.10);
  }
}

/* ---------- Launcher ---------- */
.tr-launch {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 16px 0 8px;
  border: 0;
  border-radius: 999px;
  background: #14241B;
  color: #F4F1E8;
  font: 600 14px/1 var(--ep-sans);
  cursor: pointer;
  box-shadow: 0 14px 34px -12px rgba(10, 30, 20, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08) inset;
  transform: translateY(90px);
  opacity: 0;
  transition: transform 0.6s var(--tr-spring), opacity 0.4s var(--tr-ease), background 0.2s;
}
.tr-launch.is-in { transform: none; opacity: 1; }
.tr-launch.is-in:hover { transform: translateY(-2px); }
.tr-launch.is-hidden { transform: translateY(90px); opacity: 0; pointer-events: none; }
.tr-launch kbd {
  color: #F4F1E8;
  border: 0;
  box-shadow: none;
  font: 600 12px/1 var(--ep-sans);
  padding: 4px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  margin-inline-start: 2px;
}
.tr-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1E5E3F;
  color: #F4F1E8;
}
.tr-mark svg { width: 15px; height: 15px; }
.tr-launch.is-in .tr-mark { animation: tr-breathe 2.8s ease-in-out 2s infinite; }
@keyframes tr-breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(111, 207, 151, 0.0); }
  50% { box-shadow: 0 0 0 6px rgba(111, 207, 151, 0.22); }
}
.tr-badge:empty { display: none; }
.tr-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: #6FCF97;
  color: #0E2418;
  font-size: 12px;
  display: grid;
  place-items: center;
}
.tr-launch.has-new { animation: tr-bounce 0.7s var(--tr-spring); }
@keyframes tr-bounce {
  0% { transform: none; }
  30% { transform: translateY(-10px) scale(1.04); }
  60% { transform: translateY(0) scale(0.98); }
  100% { transform: none; }
}

/* ---------- Panel ---------- */
.tr-root { position: fixed; inset: 0; z-index: 90; }
.tr-root[hidden] { display: none; }
.tr-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 14, 0.28);
  opacity: 0;
  transition: opacity 0.25s var(--tr-ease);
}
.tr-panel {
  position: absolute;
  left: 50%;
  top: max(72px, 12vh);
  width: min(860px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--tr-panel);
  color: var(--ep-ink);
  box-shadow: var(--tr-shadow);
  overflow: hidden;
  opacity: 0;
  transform: translate(-50%, -14px) scale(0.965);
  transform-origin: 50% 0;
  transition: opacity 0.22s var(--tr-ease), transform 0.42s var(--tr-spring);
}
.tr-root.is-open .tr-backdrop { opacity: 1; }
.tr-root.is-open .tr-panel { opacity: 1; transform: translate(-50%, 0) scale(1); }

.tr-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 10px; }
.tr-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--ep-bg);
  box-shadow: 0 0 0 1px var(--ep-line) inset;
  transition: box-shadow 0.2s;
}
.tr-search:focus-within { box-shadow: 0 0 0 2px var(--ep-brand) inset; }
.tr-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  color: inherit;
  font: 500 16px/1 var(--ep-sans);
}
.tr-search input::-webkit-search-cancel-button { display: none; }
.tr-ico { display: inline-grid; place-items: center; color: var(--ep-muted); }
.tr-ico svg { width: 18px; height: 18px; }
.tr-close {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: var(--ep-card);
  color: var(--ep-muted);
  font: 600 12px/1 var(--ep-sans);
  cursor: pointer;
}

.tr-filters { display: flex; gap: 6px; padding: 0 14px 10px; overflow-x: auto; scrollbar-width: none; }
.tr-filter {
  flex: none;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ep-muted);
  font: 600 13px/1 var(--ep-sans);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.tr-filter:hover { background: var(--ep-card); }
.tr-filter.is-on { background: var(--ep-action); color: var(--ep-on-action); }

.tr-tip {
  margin: 0 14px 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--ep-select);
  color: var(--ep-ink);
  font-size: 13px;
  line-height: 1.45;
}
.tr-tip b { color: var(--ep-brand); }

.tr-split { flex: 1; min-height: 0; display: flex; }
.tr-list { flex: 1; min-width: 0; overflow-y: auto; padding: 4px 8px 8px; overscroll-behavior: contain; }
.tr-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 11px;
  cursor: pointer;
  animation: tr-in 0.42s var(--tr-spring) both;
  animation-delay: var(--d, 0ms);
  transition: background 0.14s;
}
.tr-row.is-sel { background: var(--tr-row-sel); }
.tr-row.is-new { animation: tr-new 0.7s var(--tr-spring) both; }
.tr-row.is-copied { animation: tr-copied 0.45s var(--tr-ease); }
@keyframes tr-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes tr-new {
  0% { opacity: 0; transform: translateY(-14px) scale(0.97); }
  60% { opacity: 1; }
  100% { transform: none; }
}
@keyframes tr-copied {
  0% { transform: scale(1); }
  40% { transform: scale(0.985); background: var(--ep-brand-soft); }
  100% { transform: scale(1); }
}

.tr-thumb {
  flex: none;
  width: 54px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--ep-card);
  color: var(--ep-brand);
  box-shadow: 0 0 0 1px rgba(20, 36, 27, 0.08) inset;
}
.tr-thumb img { width: 100%; height: 100%; object-fit: cover; }
.tr-shot {
  display: block;
  padding: 7px 6px 0;
  background: #fff;
  color: #14241B;
  font-size: 5.5px;
  line-height: 1.35;
  text-align: start;
}
.tr-shot .tr-shot-bar { display: block; height: 3px; width: 60%; border-radius: 2px; background: #9DB39A; margin-bottom: 3px; }
.tr-shot.tone-red .tr-shot-bar { background: #D9705A; }
.tr-shot b { display: block; font-size: 6.5px; font-weight: 800; }
.tr-shot span { display: block; color: #5A6158; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-shot mark { background: #F5D76E; color: inherit; border-radius: 1px; }

.tr-body { flex: 1; min-width: 0; }
.tr-main {
  font-size: 14.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tr-main small { font-weight: 500; color: var(--ep-muted); margin-inline-start: 6px; }
.tr-main mark { background: rgba(245, 215, 110, 0.7); color: inherit; border-radius: 3px; padding: 0 1px; }
.tr-meta { margin-top: 3px; font-size: 12.5px; color: var(--ep-muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tr-ocr, .tr-mine {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--ep-select);
  color: var(--ep-brand);
}
.tr-ocr { animation: tr-pop 0.4s var(--tr-spring); }
@keyframes tr-pop { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }
.tr-num { flex: none; font-size: 11.5px; font-weight: 600; color: var(--ep-muted); opacity: 0.75; }

.tr-empty { padding: 30px 12px; text-align: center; color: var(--ep-muted); font-size: 14px; }

.tr-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--ep-line);
  font-size: 12px;
  color: var(--ep-muted);
}
.tr-k b { font-weight: 700; color: var(--ep-ink); margin-inline-end: 3px; }
.tr-note { margin-inline-start: auto; }

/* ---------- Preview (wide screens) ---------- */
.tr-preview {
  flex: 0 0 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 14px 14px 6px;
}
.tr-pv {
  flex: 1;
  min-height: 190px;
  max-height: 300px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--ep-card);
  box-shadow: 0 0 0 1px rgba(20, 36, 27, 0.08) inset;
  display: grid;
  place-items: center;
  animation: tr-pv 0.35s var(--tr-spring);
}
@keyframes tr-pv { from { opacity: 0.4; transform: scale(0.98); } to { opacity: 1; transform: none; } }
.tr-pv img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.tr-pv-text {
  align-self: start;
  justify-self: stretch;
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  max-height: 100%;
}
.tr-pv-code .tr-pv-text { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.tr-pv-text mark, .tr-pv-shot mark { background: #F5D76E; color: #14241B; border-radius: 3px; padding: 0 1px; box-shadow: 0 0 0 3px rgba(245, 215, 110, 0.35); }
.tr-pv-hex { padding: 6px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.92); color: #14241B; font: 700 14px/1 var(--ep-sans); }
.tr-pv-shot { display: block; background: #fff; color: #14241B; }
.tr-pv-bar { display: flex; gap: 5px; padding: 9px 10px; background: #ECE6D8; }
.tr-pv-bar i { width: 8px; height: 8px; border-radius: 50%; background: #D9D1BF; }
.tr-pv-page { padding: 16px 16px 0; display: flex; flex-direction: column; gap: 7px; text-align: start; }
.tr-pv-page b { font-size: 17px; font-weight: 800; padding-top: 10px; border-top: 4px solid #9DB39A; }
.tr-pv-shot.tone-red .tr-pv-page b { border-top-color: #D9705A; }
.tr-pv-page span { font-size: 13px; color: #5A6158; }
.tr-pv-page em { display: block; height: 7px; width: 85%; border-radius: 4px; background: #ECE6D8; margin-top: 4px; }
.tr-pv-page em.w2 { width: 60%; }
.tr-pv-info { font-size: 12.5px; color: var(--ep-muted); }
.tr-pv-copy {
  height: 40px;
  border: 0;
  border-radius: 10px;
  background: var(--ep-action);
  color: var(--ep-on-action);
  font: 600 14px/1 var(--ep-sans);
  cursor: pointer;
  transition: transform 0.15s var(--tr-ease);
}
.tr-pv-copy:hover { transform: translateY(-1px); }
@media (max-width: 760px) { .tr-preview { display: none; } }

/* ---------- Toast ---------- */
.tr-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 95;
  padding: 12px 18px;
  border-radius: 12px;
  background: #14241B;
  color: #F4F1E8;
  font: 600 14px/1.3 var(--ep-sans);
  box-shadow: 0 16px 40px -14px rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 20px);
  transition: opacity 0.25s var(--tr-ease), transform 0.45s var(--tr-spring);
}
.tr-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Hero button ---------- */
.hero-ctas { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 12px; margin-top: 30px; }
.hero-ctas .hero-cta { margin-top: 0; }
.hero-try {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  background: var(--ep-raised);
  color: var(--ep-ink);
  box-shadow: 0 0 0 1px var(--ep-line) inset, 0 8px 22px -14px rgba(10, 40, 25, 0.4);
  font: 600 15px/1 var(--ep-sans);
  cursor: pointer;
  transition: transform 0.2s var(--tr-ease), box-shadow 0.2s;
}
.hero-try:hover { transform: translateY(-2px); box-shadow: 0 0 0 1px var(--ep-brand-soft) inset, 0 12px 26px -14px rgba(10, 40, 25, 0.45); }
.hero-try svg { width: 16px; height: 16px; color: var(--ep-brand); }
.hero-try .arr { display: inline-block; animation: tr-nudge 1.9s ease-in-out infinite; }
@keyframes tr-nudge {
  0%, 60%, 100% { transform: translateX(0); }
  70% { transform: translateX(4px); }
  80% { transform: translateX(0); }
  88% { transform: translateX(2px); }
}
:dir(rtl) .hero-try .arr, [dir="rtl"] .hero-try .arr { transform: scaleX(-1); animation: none; }

@media (max-width: 620px) {
  .tr-launch { right: 12px; bottom: 12px; }
  .tr-panel { top: 64px; max-height: calc(100vh - 80px); }
  .tr-k-hide, .tr-num { display: none; }
  .tr-foot .tr-k { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tr-launch, .tr-panel, .tr-backdrop, .tr-toast { transition: none; }
  .tr-row, .tr-row.is-new, .tr-pv, .tr-launch.has-new, .tr-launch.is-in .tr-mark, .hero-try .arr, .tr-ocr { animation: none; }
}
