/* Gameficate Craft — Templates step and the template library window. */
/* ---------- templates ---------- */
nav.side button.tpl-nav {
  margin-bottom: 6px;
  border: 2px dashed var(--line);
}
nav.side button.tpl-nav .num {
  font-size: 15px;
  background: #fff1e8;
}
.chip {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--soft);
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.chip:hover {
  border-color: #bfd0e0;
  background: #fff;
}
.tpl-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: -8px 0 18px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #fff7ef;
  border: 2px dashed #ffd3b8;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}
.tpl-search {
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 2px solid var(--line);
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  min-width: 0;
}
.tpl-search:focus {
  outline: none;
  border-color: var(--orange);
}
.tpl-search.big {
  flex: 1 1 260px;
  max-width: 460px;
}
.tpl-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.tpl-tile {
  display: grid;
  grid-template-columns: 48px 1fr;
  grid-template-rows: auto auto 1fr;
  column-gap: 12px;
  row-gap: 2px;
  text-align: left;
  padding: 16px;
  border-radius: 18px;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--navy);
  align-items: start;
}
.tpl-tile:hover,
.tpl-tile:focus-visible {
  border-color: var(--orange);
  box-shadow: 0 6px 18px rgba(23, 50, 77, 0.1);
  outline: none;
}
.tpl-tile .ic {
  grid-row: 1 / span 3;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 26px;
  background: var(--soft);
}
.tpl-tile b {
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.2;
}
.tpl-tile .cnt {
  font-size: 13px;
  font-weight: 900;
  color: var(--orange-d);
}
.tpl-tile .sub {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 4px;
}
.tpl-tile.mine {
  background: #fffbea;
  border-style: dashed;
}
.tpl-dev summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--navy);
}
.tpl-dev code {
  background: var(--soft);
  padding: 1px 5px;
  border-radius: 5px;
}
/* ---------- Template library window ---------- */
.tpl-bg {
  z-index: 4500;
}
.tpl-win {
  width: min(1240px, 96vw);
  height: min(860px, 92vh);
  background: var(--bg);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}
.tpl-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  color: #fff;
}
.tpl-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  white-space: nowrap;
}
.tpl-head .tpl-search {
  flex: 1;
  max-width: 520px;
  margin-left: auto;
  border-color: transparent;
}
.tpl-x {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 900;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  flex: 0 0 auto;
}
.tpl-x:hover {
  background: rgba(255, 255, 255, 0.26);
}
.tpl-body {
  flex: 1;
  display: flex;
  min-height: 0;
}
.tpl-rail {
  width: 250px;
  flex: 0 0 auto;
  padding: 14px 10px;
  background: #fff;
  border-right: 2px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tpl-rail button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  text-align: left;
  font-weight: 800;
  font-size: 14.5px;
  color: var(--navy);
}
.tpl-rail button:hover {
  background: var(--soft);
}
.tpl-rail button.on {
  background: #fff1e8;
  color: var(--orange-d);
}
.tpl-rail .ic {
  width: 26px;
  text-align: center;
  font-size: 18px;
  flex: 0 0 auto;
}
.tpl-rail .lb {
  flex: 1;
  min-width: 0;
}
.tpl-rail b {
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
  background: var(--soft);
  border-radius: 999px;
  padding: 2px 8px;
}
.tpl-sep {
  height: 2px;
  background: var(--line);
  margin: 8px 6px;
}
.tpl-main {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px 30px;
  min-width: 0;
  outline: none;
}
.tpl-col + .tpl-col {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 2px solid var(--line);
}
.tpl-colhead h3 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  color: var(--navy);
}
.tpl-colhead p {
  margin: 4px 0 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  max-width: 820px;
  line-height: 1.45;
}
.tpl-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  position: sticky;
  top: -18px;
  z-index: 2;
  padding: 8px 0;
  background: var(--bg);
}
.tpl-grp {
  scroll-margin-top: 56px;
}
.tpl-grp h5 {
  margin: 16px 0 8px;
  font-size: 15px;
  font-weight: 900;
  color: var(--navy);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.tpl-grp h5 span {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}
/* ---------- Template cards ---------- */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}
.tpl-card {
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-card:hover {
  border-color: #bfd0e0;
  box-shadow: 0 4px 14px rgba(23, 50, 77, 0.08);
}
.tpl-card.mine {
  background: #fffbea;
}
.tpl-card h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  color: var(--navy);
  line-height: 1.3;
}
.tpl-where {
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.3px;
  color: var(--orange-d);
  text-transform: uppercase;
}
.tpl-meta {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--muted);
}
.tpl-desc {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tpl-types {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tpl-types span {
  font-size: 11.5px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e9f5ff;
  color: #1d5e8f;
}
.tpl-acts {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
  flex-wrap: wrap;
}
.tpl-card.mine .tpl-acts {
  flex-wrap: nowrap;
}
.tpl-card.mine .tpl-acts .btn:not(.pri) {
  padding: 0 8px;
}
.tpl-empty {
  padding: 30px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
  background: #fff;
  border: 2px dashed var(--line);
  border-radius: 16px;
}
@media (max-width: 760px) {
  .tpl-rail {
    width: 64px;
  }
  .tpl-rail .lb,
  .tpl-rail b {
    display: none;
  }
  .tpl-head h2 {
    font-size: 0;
  }
  .tpl-head h2::first-letter {
    font-size: 22px;
  }
}

/* Free / premium badge on a template card (templates.json "tier"; deployment.js premium). */
.tpl-tier {
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.3px;
  background: #e8f6ef;
  color: #137a4d;
}
.tpl-tier.premium {
  background: linear-gradient(135deg, #fff1c9, #ffe08a);
  color: #7a5200;
}

/* ---------- 👁 Template preview and the ★ premium add-on dialog (js/templates/TemplatePreview.js, js/model/Premium.js) ---------- */
.modal-bg.premium-bg {
  z-index: 4800;
}
.tpl-tier.premium.locked {
  background: #eef1f5;
  color: #5b6b7c;
  border-color: #cfd8e3;
}
.modal.premium-modal {
  width: min(560px, 94vw);
}
.premium-list {
  margin: 10px 0 0 20px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}
.modal.tpl-preview {
  width: min(820px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}
.tpl-preview .tp-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tpl-preview .tp-head h3 {
  flex: 1;
  margin: 0;
}
.tpl-preview .tp-body {
  flex: 1;
  overflow: auto;
  margin-top: 10px;
  border-top: 2px solid var(--line);
  padding-top: 8px;
}
.tp-list {
  margin: 0;
  padding-left: 30px;
}
.tp-list li {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.tp-type,
.tp-diff {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--soft, #eef4f9);
  font-size: 12px;
  font-weight: 800;
  color: var(--navy);
}
.tp-q {
  font-weight: 700;
}
.tp-extra {
  margin-left: 6px;
}
