/* Templates library — layout aligned with dashboard/shop */

.templates-page .dash-shell.tpl-shell {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem var(--page-pad) 3rem;
  box-sizing: border-box;
}

.templates-page .dash-frame.tpl-frame {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.75rem 2rem;
  border-radius: 24px;
  border-width: 2px;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.tpl-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.tpl-hero-text {
  flex: 1 1 280px;
  min-width: 0;
}

.tpl-hero h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 2.8vw, 2.15rem);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.tpl-hero .muted {
  margin: 0;
  font-size: 0.95rem;
  max-width: 52ch;
}

.tpl-create-btn {
  flex-shrink: 0;
  align-self: center;
  white-space: nowrap;
}

.tpl-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding-top: 0.15rem;
}

.tpl-tab {
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
  opacity: 0.72;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}

.tpl-tab.active {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.tpl-tab:hover:not(.active) {
  opacity: 1;
  background: rgba(255, 255, 255, 0.04);
}

.tpl-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
}

.tpl-search {
  width: 100%;
  min-width: 0;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  color: inherit;
  font: inherit;
}

.tpl-search:focus {
  outline: none;
  border-color: rgba(88, 101, 242, 0.55);
}

.tpl-sort-wrap {
  min-width: 148px;
}

.tpl-sort {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.28);
  color: inherit;
  font: inherit;
}

.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
  width: 100%;
}

.tpl-card {
  border: 2px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.tpl-card-preview {
  position: relative;
  aspect-ratio: 16 / 10;
  background: linear-gradient(145deg, #12121a, #0a0a0f);
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  border: 0;
  padding: 0;
  width: 100%;
  text-align: left;
  font: inherit;
}

.tpl-card-preview:focus-visible {
  outline: 2px solid rgba(88, 101, 242, 0.65);
  outline-offset: 2px;
}

.tpl-card-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tpl-card-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e, #16213e 50%, #0f0f0f);
}

.tpl-card-badges {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  z-index: 1;
}

.tpl-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tpl-badge-premium { background: rgba(255, 255, 255, 0.18); color: #fff; border: 1px solid rgba(255, 255, 255, 0.35); }
.tpl-badge-customer { background: rgba(255, 255, 255, 0.12); color: #fff; border: 1px solid rgba(255, 255, 255, 0.28); }
.tpl-badge-paid { background: #57f287; color: #111; }

.tpl-fav-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  z-index: 1;
}

.tpl-fav-btn.is-active { color: #fee75c; }

.tpl-card-body {
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.tpl-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.tpl-card-author {
  font-size: 12px;
  opacity: 0.7;
}

.tpl-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  opacity: 0.75;
}

.tpl-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tpl-card-price {
  font-size: 0.84rem;
  font-weight: 650;
  margin-top: 0.15rem;
}

.tpl-card-price-free {
  color: #57f287;
}

.tpl-card-price-paid {
  color: #57f287;
}

.tpl-tag {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(88, 101, 242, 0.18);
}

.tpl-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 6px;
}

.tpl-card-actions .btn-primary {
  flex: 1;
  min-width: 0;
}

.tpl-icon-btn {
  min-width: 38px;
  padding-inline: 8px;
}

.tpl-empty {
  text-align: center;
  padding: 2.5rem 1rem;
  grid-column: 1 / -1;
}

.tpl-load-more-wrap {
  text-align: center;
  padding-top: 0.25rem;
}

/* Apply template modal */
.tpl-apply-modal[hidden] {
  display: none !important;
}

.tpl-apply-modal:not([hidden]) {
  display: flex;
}

.tpl-apply-card {
  width: min(520px, 100%);
  padding: 1.25rem 1.35rem 1.35rem;
  border-radius: 20px;
  background: rgba(14, 14, 14, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.tpl-apply-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.tpl-apply-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
}

.tpl-apply-close {
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.tpl-apply-preview {
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: #0a0a0f;
  margin-bottom: 0.85rem;
}

.tpl-apply-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tpl-apply-meta {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0.85rem;
}

.tpl-apply-lead {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  opacity: 0.85;
}

.tpl-apply-modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.tpl-mode-card {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tpl-mode-card strong {
  font-size: 0.92rem;
}

.tpl-mode-card span {
  font-size: 0.78rem;
  line-height: 1.35;
}

.tpl-mode-card.active {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.1);
}

.tpl-apply-resources-label {
  margin: 0 0 0.5rem;
  font-size: 0.88rem;
  opacity: 0.85;
}

.tpl-resource-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.tpl-resource-btn {
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
  font-size: 0.82rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  min-height: 3.1rem;
}

.tpl-resource-btn.is-blocked {
  opacity: 0.45;
  cursor: not-allowed;
}

.tpl-res-label {
  line-height: 1.25;
}

.tpl-res-reqs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.tpl-res-req {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.12rem 0.35rem;
  border-radius: 999px;
  line-height: 1.2;
}

.tpl-res-req-premium {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.tpl-res-req-customer {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.tpl-resource-btn.active {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.1);
}

.tpl-buy-notice {
  display: none;
  padding: 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 0.75rem;
}

.tpl-buy-notice.show {
  display: block;
}

.tpl-buy-notice p {
  margin: 0 0 0.55rem;
  font-size: 0.9rem;
}

.tpl-buy-actions {
  display: flex;
  gap: 0.45rem;
}

.tpl-apply-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.tpl-card-owner-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tpl-danger-btn {
  color: #f0a0a0 !important;
}

.templates-page .topbar {
  position: sticky;
  z-index: 120;
}

/* Create template */
.templates-page .tpl-create-frame {
  max-width: 680px;
  margin: 0 auto;
}

.tpl-create-head {
  margin-bottom: 0.5rem;
}

.tpl-create-head h1 {
  margin: 0.75rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
}

.tpl-create-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tpl-sections-fieldset {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0;
}

.tpl-sections-fieldset .checkbox-row {
  margin: 0 0 0.5rem;
}

.tpl-sections-fieldset .checkbox-row:last-of-type {
  margin-bottom: 0;
}

.tpl-create-form > .checkbox-row {
  margin-top: 0.15rem;
}

.tpl-sections-fieldset legend {
  padding: 0 6px;
  font-weight: 600;
}

.tpl-sections-note {
  font-size: 13px;
  margin: 0 0 10px;
}

.tpl-snapshot-note {
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(88, 101, 242, 0.12);
  border: 1px solid rgba(88, 101, 242, 0.28);
  font-size: 0.86rem;
}

.tpl-snapshot-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.92rem;
  opacity: 0.9;
}

.tpl-create-actions {
  margin-top: 0.25rem;
}

/* Create modal (guns.lol style) */
.tpl-create-overlay[hidden] {
  display: none !important;
}

.tpl-create-overlay:not([hidden]) {
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
}

body.tpl-modal-open {
  overflow: hidden;
}

.tpl-create-shell {
  display: flex;
  justify-content: center;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

.tpl-create-overlay .tpl-create-modal,
.tpl-create-shell .tpl-create-modal {
  width: min(400px, calc(100vw - 2.5rem));
  max-width: 400px;
  margin: 0 auto;
  flex-shrink: 0;
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(12, 12, 14, 0.96);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.5);
}

.tpl-create-modal {
  width: min(400px, calc(100vw - 2.5rem));
  max-width: 400px;
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(12, 12, 14, 0.96);
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.5);
}

.tpl-create-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.tpl-create-modal-head h1,
.tpl-create-modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tpl-create-close {
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  opacity: 0.85;
  transition: background 0.15s, opacity 0.15s;
}

.tpl-create-close:hover {
  background: rgba(255, 255, 255, 0.12);
  opacity: 1;
}

.tpl-create-lead {
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.tpl-field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.tpl-field-label {
  font-size: 0.88rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tpl-field-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.04);
  font-size: 10px;
  font-weight: 700;
  opacity: 0.85;
  cursor: help;
  padding: 0;
  color: inherit;
  position: relative;
  flex-shrink: 0;
}

.tpl-field-tip-popup {
  display: none;
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: min(240px, 70vw);
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: rgba(18, 18, 22, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  z-index: 30;
  pointer-events: none;
}

.tpl-field-tip.is-open .tpl-field-tip-popup,
.tpl-field-tip:hover .tpl-field-tip-popup {
  display: block;
}

.tpl-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.tpl-input-icon {
  position: absolute;
  left: 12px;
  font-size: 0.82rem;
  opacity: 0.55;
  pointer-events: none;
  z-index: 1;
}

.tpl-input-wrap input,
.tpl-input-wrap select,
.tpl-tags-input-row input {
  width: 100%;
  padding: 0.72rem 0.85rem 0.72rem 2.35rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font: inherit;
  box-sizing: border-box;
}

.tpl-input-wrap input:focus,
.tpl-input-wrap select:focus,
.tpl-tags-input-row input:focus {
  outline: none;
  border-color: rgba(88, 101, 242, 0.55);
}

.tpl-select-wrap select {
  appearance: none;
  cursor: pointer;
  padding-right: 2rem;
  background-image: linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.55) 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.55) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% + 2px), calc(100% - 12px) calc(50% + 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.tpl-preview-drop {
  position: relative;
  border-radius: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.35);
  min-height: 120px;
  max-height: 160px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.tpl-preview-drop:hover {
  border-color: rgba(88, 101, 242, 0.45);
  background: rgba(88, 101, 242, 0.06);
}

.tpl-preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 120px;
  padding: 1rem;
  text-align: center;
  font-size: 0.82rem;
  opacity: 0.65;
}

.tpl-preview-icon {
  font-size: 1.75rem;
  opacity: 0.5;
}

.tpl-preview-filled {
  position: relative;
  min-height: 120px;
  max-height: 160px;
}

.tpl-preview-filled img,
.tpl-preview-img {
  width: 100%;
  height: 100%;
  min-height: 120px;
  max-height: 160px;
  object-fit: cover;
  display: block;
}

.tpl-preview-clear {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 0;
  border-radius: 10px;
  padding: 0.35rem 0.65rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.78rem;
  cursor: pointer;
}

.tpl-tags-editor {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.tpl-tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 0;
}

.tpl-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.55rem 0.28rem 0.65rem;
  font-size: 0.78rem;
  background: rgba(88, 101, 242, 0.22);
  border: 1px solid rgba(88, 101, 242, 0.35);
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.tpl-tag-chip:active {
  cursor: grabbing;
}

.tpl-tag-chip.is-dragging {
  opacity: 0.45;
}

.tpl-tag-chip.is-drag-over {
  border-color: rgba(74, 222, 128, 0.7);
  background: rgba(34, 197, 94, 0.12);
}

.tpl-tag-text {
  pointer-events: none;
}

.tpl-tag-remove {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  opacity: 0.75;
  flex-shrink: 0;
}

.tpl-tag-remove:hover {
  opacity: 1;
}

.tpl-tags-input-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.tpl-tags-input-row input {
  flex: 1;
  min-width: 0;
}

.tpl-tag-add {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s;
}

.tpl-tag-add:hover {
  background: rgba(88, 101, 242, 0.35);
}

.tpl-sections-field {
  gap: 0.55rem;
}

.tpl-sections-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.4;
}

.tpl-sections-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  max-height: 300px;
  overflow-y: auto;
  padding: 0.15rem 0.1rem 0.25rem;
}

.tpl-section-tile {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 3.1rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1.3;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.tpl-section-tile-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.tpl-section-tile-label {
  display: block;
}

.tpl-section-tile:hover {
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
}

.tpl-section-tile.is-on,
.tpl-section-tile:has(.tpl-section-tile-input:checked) {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.1);
}

.tpl-create-submit {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.85rem 1rem;
  border-radius: 999px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.tpl-create-submit span {
  font-size: 1.15rem;
  line-height: 1;
}

.tpl-advanced {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 0.75rem 1rem;
}

.tpl-advanced summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.tpl-advanced .field {
  margin-top: 0.75rem;
}

/* Template detail page */
.templates-page .dash-shell.tpl-view-shell {
  max-width: 580px;
  padding-top: 0.75rem;
  padding-bottom: 2rem;
}

.tpl-view-shell {
  max-width: 580px;
  margin: 0 auto;
}

.tpl-view-top {
  margin-bottom: 0.75rem;
}

.tpl-view-card {
  overflow: hidden;
  border-radius: 22px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
}

.tpl-view-preview {
  position: relative;
  aspect-ratio: 16 / 10;
  max-height: 320px;
  background: linear-gradient(145deg, #12121a, #0a0a0f);
  overflow: hidden;
}

.tpl-view-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tpl-view-body {
  padding: 1rem 1.15rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tpl-view-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tpl-view-desc {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.62);
  white-space: pre-wrap;
}

.tpl-card-desc {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.55);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tpl-view-author {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  opacity: 0.75;
  text-decoration: none;
  color: inherit;
  width: fit-content;
}

.tpl-view-author img {
  border-radius: 999px;
  object-fit: cover;
}

.tpl-view-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  font-size: 0.78rem;
  opacity: 0.78;
}

.tpl-view-trend {
  color: #57f287;
}

.tpl-view-price-row {
  margin-top: 0.1rem;
}

.tpl-view-price {
  font-size: 0.9rem;
  font-weight: 650;
}

.tpl-view-price-free {
  color: #57f287;
}

.tpl-view-price-paid {
  color: #57f287;
}

.tpl-view-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tpl-view-tags .tpl-tag {
  font-size: 0.72rem;
  padding: 0.22rem 0.65rem;
  background: rgba(88, 101, 242, 0.25);
  border: 1px solid rgba(88, 101, 242, 0.35);
}

.tpl-view-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.5rem;
  align-items: center;
  min-width: 0;
}

.tpl-view-use {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  border-radius: 999px;
  padding: 0.62rem 0.85rem;
  font-weight: 650;
  font-size: 0.84rem;
  overflow: hidden;
}

.tpl-view-use-label {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-view-side-actions {
  display: flex;
  flex-shrink: 0;
  gap: 0.35rem;
  align-items: center;
}

.tpl-view-actions .tpl-icon-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 0.95rem;
}

.tpl-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.tpl-card-title a {
  color: inherit;
  text-decoration: none;
}

.tpl-card-title a:hover {
  text-decoration: underline;
}

/* Profile template preview banner — never inherit profile --p / theme link colors */
.tpl-preview-bar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 14px 12px 16px;
  border-radius: 18px;
  background: rgba(14, 14, 14, 0.94) !important;
  border: 1px solid rgba(255, 255, 255, 0.18) !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  max-width: min(94vw, 540px);
  color: #fff !important;
}

.tpl-preview-bar,
.tpl-preview-bar * {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

.tpl-preview-bar-text {
  min-width: 0;
  flex: 1;
}

.tpl-preview-bar-text strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tpl-preview-bar-text span {
  display: block;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.62) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.62) !important;
  margin-top: 1px;
}

.tpl-preview-bar-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.48) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.48) !important;
  margin-bottom: 3px;
  font-weight: 600;
}

.tpl-preview-bar-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.55) !important;
  background: transparent !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tpl-preview-bar-btn:hover,
.tpl-preview-bar-btn:focus,
.tpl-preview-bar-btn:visited {
  background: rgba(255, 255, 255, 0.08) !important;
  border-color: #fff !important;
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

@media (max-width: 720px) {
  .templates-page .dash-frame.tpl-frame {
    padding: 1rem;
  }

  .tpl-toolbar {
    grid-template-columns: 1fr;
  }

  .tpl-sort-wrap {
    min-width: 0;
  }

  .tpl-grid {
    grid-template-columns: 1fr;
  }

  .tpl-create-btn {
    width: 100%;
  }

  .tpl-create-overlay .tpl-create-modal,
  .tpl-create-shell .tpl-create-modal {
    width: min(100%, calc(100vw - 1.5rem));
  }

  .templates-page .dash-shell.tpl-view-shell {
    max-width: none;
  }
}
