/* Template Studio v2 (tp2-) — gallery, live thumbnails, preview, brand kit */

.tp2-page {
  max-width: min(1500px, 100%);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--sd-ink, #0f172a);
}
.tp2-safe {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: #147c3d;
  background: rgba(22, 163, 74, 0.09);
  border: 1px solid rgba(22, 163, 74, 0.2);
  border-radius: 999px;
  padding: 8px 14px;
}
.tp2-safe svg { width: 14px; height: 14px; }

/* library strip */
.tp2-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.tp2-lib-item {
  border: 1px solid var(--sd-line, #e3e9f2);
  border-radius: 13px;
  padding: 12px 14px;
  background: #fbfcfe;
}
.tp2-lib-item b { display: block; font-size: 13.5px; }
.tp2-lib-item small { display: block; color: var(--sd-mut, #5b6b82); font-size: 12px; margin: 2px 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp2-lib-actions { display: flex; gap: 6px; }

/* gallery */
.tp2-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.tp2-card {
  background: #fff;
  border: 1px solid var(--sd-line, #e3e9f2);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 14px rgba(15, 23, 42, 0.05);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  display: flex;
  flex-direction: column;
}
.tp2-card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(15, 23, 42, 0.05), 0 14px 34px rgba(15, 23, 42, 0.1); }
.tp2-thumb {
  height: 210px;
  overflow: hidden;
  position: relative;
  background: #f4f6fb;
  border-bottom: 1px solid #eef2f8;
  pointer-events: none;
}
.tp2-thumb iframe {
  width: 200%;
  height: 420px;
  border: 0;
  transform: scale(0.5);
  transform-origin: top left;
  pointer-events: none;
}
.tp2-meta { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 13px 14px 6px; }
.tp2-meta b { display: block; font-size: 14px; }
.tp2-meta small { display: block; color: var(--sd-mut, #5b6b82); font-size: 12px; margin-top: 2px; }
.tp2-actions { display: flex; gap: 7px; padding: 8px 14px 14px; margin-top: auto; }
.tp2-actions .sd-btn { flex: 1; justify-content: center; }

/* preview modal */
.tp2-modal {
  position: fixed;
  inset: 0;
  z-index: 230;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.tp2-preview-card {
  background: #f1f4fa;
  border-radius: 18px;
  width: min(860px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
}
.tp2-preview-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e8edf5;
}
.tp2-preview-bar b { font-size: 14.5px; margin-right: auto; }
.tp2-preview-body { overflow: auto; padding: 22px; display: flex; justify-content: center; }
.tp2-preview-body iframe { border: 0; height: 72vh; border-radius: 12px; background: transparent; }

/* brand kit */
.tp2-brand .cr-modal-body { max-height: 76vh; }
.tp2-bgs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -4px 0 4px; }
.tp2-bg {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 2px solid #dbe3ef;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.tp2-bg:hover { transform: translateY(-2px); }
.tp2-bg.active { border-color: #367ef5; box-shadow: 0 0 0 3px rgba(54, 126, 245, 0.15); }

@media (max-width: 760px) {
  .tp2-grid { grid-template-columns: 1fr 1fr; }
  .tp2-thumb { height: 170px; }
}

/* Confirmation for actions that reach the server, so a design that failed to
   save does not look identical to one that saved. */
.tp2-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 11px 17px;
  border-radius: 10px;
  font-size: 13.5px;
  max-width: min(560px, 92vw);
  background: #11151c;
  color: #f2f4f8;
  box-shadow: 0 12px 34px rgba(8, 10, 16, 0.3);
}
@media (prefers-color-scheme: dark) {
  .tp2-toast { background: #e9edf4; color: #11151c; }
}
