/* /tp/ pages, the preview bar and the "Use this template" popup (shared with the gallery).
   Generated pages: scripts/build-tp.mjs. Uses the tokens in /styles.css. */

.pl-offscreen { position: absolute; left: -9999px; top: 0; }

/* --- "Use this template" popup ------------------------------------------- */
.pl-use {
  width: min(520px, calc(100vw - 32px));
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: var(--s-6) var(--s-5) var(--s-5);
  box-shadow: var(--pop);
}
.pl-use::backdrop { background: rgba(35, 34, 29, 0.45); }
.pl-use-h { font: 600 24px/1.2 var(--body); margin: 0 0 var(--s-4); color: var(--ink); }
.pl-use-prompt {
  display: block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--s-4);
  font: 500 16px/1.5 var(--mono);
  color: var(--ink);
  overflow-wrap: anywhere;
  user-select: all;
}
.pl-use-note { margin: var(--s-4) 0 var(--s-5); font-size: var(--fs-body); color: var(--ink); }
.pl-use-ok { min-width: 120px; }
.pl-use-x {
  position: absolute; top: 8px; right: 8px;
  width: 44px; height: 44px;
  border: 0; border-radius: 999px; background: none;
  font: 400 28px/1 var(--body); color: var(--muted); cursor: pointer;
}
.pl-use-x:hover { background: var(--bg); color: var(--ink); }

/* --- Preview wrapper: the template in a frame, a bar at the bottom ----------- */
html.pv, html.pv body { height: 100%; margin: 0; overflow: hidden; background: var(--paper); }
.pv body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.pv-frame { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; display: block; background: #fff; }
.pv-bar {
  flex: none;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px var(--gutter);
  padding-bottom: max(10px, env(safe-area-inset-bottom));
  background: var(--field);
  border-top: 2px solid var(--line-strong);
  color: var(--ink);
}
.pv-bar[hidden] { display: none; }
.pv-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 600 16px/1.2 var(--body); margin-right: auto; min-height: 44px; }
.pv-brand img { width: 32px; height: 32px; flex: none; }
.pv-bar .btn { white-space: nowrap; }
.pv-x { flex: none; width: 44px; height: 44px; border: 0; border-radius: 999px; background: none; font: 400 26px/1 var(--body); color: var(--ink); cursor: pointer; }
.pv-x:hover { background: rgba(35, 34, 29, 0.08); }
@media (max-width: 420px) {
  .pv-brand { font-size: 14px; gap: 8px; }
  .pv-brand img { width: 28px; height: 28px; }
  .pv-bar { gap: 6px; }
}

/* --- /tp/<Name>: the plain page an AI (or a person) reads ------------------ */
.tp-page { padding-top: var(--s-6); padding-bottom: var(--s-8); }
.tp-page .tp-lede { font-size: var(--fs-lede); color: var(--ink); margin: 0 0 var(--s-5); max-width: 62ch; }
.tp-page h2 { margin-top: var(--s-7); }
.tp-page h3 { margin-top: var(--s-5); }
.tp-page p, .tp-page li { max-width: 72ch; }
.tp-page li { margin: 6px 0; }
.tp-page pre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s-4); overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.tp-page code { overflow-wrap: anywhere; }
.tp-shot { display: block; max-width: 720px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 0 0 var(--s-5); }
.tp-shot img { display: block; width: 100%; height: auto; }
.tp-use { display: flex; flex-wrap: wrap; gap: var(--s-3); margin: 0 0 var(--s-5); }
