/* 한국형 템플릿 스튜디오 (카페24 디자인센터 UX 참고 · 라이트/다크 모드 완벽 대응) */

.tpl-studio-toolbar {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.tpl-studio-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.tpl-studio-title {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.tpl-studio-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.tpl-studio-head-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tpl-studio-meta-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(234, 88, 12, 0.12);
  color: var(--accent, #ea580c);
  border: 1px solid rgba(234, 88, 12, 0.25);
}

/* 1차 대분류 10대 카테고리 + 전체 (2줄 균형 그리드) */
.tpl-studio-tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
  border-radius: 16px;
  background: var(--bg-surface-subtle, rgba(148, 163, 184, 0.1));
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.24));
}

@media (max-width: 1120px) {
  .tpl-studio-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .tpl-studio-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tpl-studio-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 9px 8px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.tpl-studio-tab:hover {
  background: rgba(234, 88, 12, 0.08);
}

.tpl-studio-tab.is-active {
  background: var(--bg-surface, #ffffff);
  border-color: var(--accent, #ea580c);
  box-shadow: 0 4px 14px rgba(234, 88, 12, 0.16);
}

.tpl-studio-tab__top {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14.5px;
}

.tpl-studio-tab.is-active .tpl-studio-tab__top strong {
  color: var(--accent, #ea580c);
}

.tpl-studio-tab__count {
  font-size: 11.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  color: var(--text-muted);
}

.tpl-studio-tab.is-active .tpl-studio-tab__count {
  background: rgba(234, 88, 12, 0.14);
  color: var(--accent, #ea580c);
}

.tpl-studio-tab__sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* 2차 업종 필터 + 검색 + 정렬 */
.tpl-studio-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.tpl-studio-chips-group,
.tpl-studio-tag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.tpl-studio-filter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 2px;
}

.tpl-studio-chips,
.tpl-studio-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tpl-chip,
.tpl-tag-btn {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.3));
  background: var(--bg-surface, transparent);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
}

.tpl-chip:hover,
.tpl-tag-btn:hover {
  border-color: var(--accent, #ea580c);
}

.tpl-chip.is-active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

html[data-theme="dark"] .tpl-chip.is-active {
  background: var(--accent, #ea580c);
  border-color: var(--accent, #ea580c);
  color: #ffffff;
}

.tpl-tag-btn {
  padding: 4px 10px;
  font-size: 12px;
}

.tpl-tag-btn.is-active {
  background: rgba(234, 88, 12, 0.14);
  border-color: var(--accent, #ea580c);
  color: var(--accent, #ea580c);
}

.tpl-studio-filter-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.tpl-studio-search-wrap svg {
  position: absolute;
  left: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

.tpl-studio-search {
  width: 270px;
  max-width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: 10px;
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.35));
  background: var(--bg-surface, transparent);
  color: var(--text-primary);
  font-size: 13px;
}

.tpl-studio-sort {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.35));
  background: var(--bg-surface, transparent);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
}

.tpl-studio-result-count {
  margin-left: auto;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
}

/* 카드 그리드 (4열 반응형) */
.tpl-studio-grid {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 18px !important;
}

@media (max-width: 1280px) {
  .tpl-studio-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 860px) {
  .tpl-studio-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 560px) {
  .tpl-studio-grid {
    grid-template-columns: 1fr !important;
  }
}

.template-card--studio {
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.25));
  background: var(--bg-surface, #ffffff);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
  padding: 0 !important;
}

.template-card--studio:hover {
  transform: translateY(-3px);
  border-color: rgba(234, 88, 12, 0.45);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
}

.template-card--studio .template-card__preview {
  position: relative;
  overflow: hidden;
  background: var(--bg-surface-subtle, #f1f5f9);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.template-card--studio .template-card__preview.is-tall {
  height: 290px;
}

.template-card--studio .template-card__preview.is-square {
  height: 250px;
  align-items: center;
}

.template-card--studio .template-card__preview.is-wide {
  height: 180px;
  align-items: center;
  padding: 12px;
}

.tpl-card__canvas {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 1.6s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.template-card--studio .template-card__preview.is-tall:hover .tpl-card__canvas {
  transform: translateY(-28%);
}

.template-card--studio .template-card__preview.is-square .tpl-card__canvas,
.template-card--studio .template-card__preview.is-wide .tpl-card__canvas {
  max-height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
}

.tpl-card__top-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.tpl-card__size-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.78);
  color: #ffffff;
  backdrop-filter: blur(4px);
}

.tpl-card__flags {
  display: flex;
  gap: 4px;
}

.tpl-flag {
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
}

.tpl-flag--best {
  background: #ea580c;
  color: #ffffff;
}

.tpl-flag--new {
  background: #2563eb;
  color: #ffffff;
}

.tpl-flag--ind {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-primary);
}

.tpl-flag--tag {
  background: rgba(234, 88, 12, 0.12);
  color: var(--accent, #ea580c);
}

.tpl-card__layer-pill {
  position: absolute;
  right: 10px;
  bottom: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #f8fafc;
  pointer-events: none;
}

.tpl-card__hover-cta {
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.78), transparent);
  display: flex;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.template-card--studio .template-card__preview:hover .tpl-card__hover-cta {
  opacity: 1;
}

.tpl-card__quick-start {
  font-size: 12.5px;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(234, 88, 12, 0.32);
}

.tpl-card__body {
  padding: 14px 15px 15px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

.tpl-card__tags-line {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.tpl-card__ind {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--text-primary);
}

.tpl-card__tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent, #ea580c);
}

.template-card--studio .template-card__name {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.38;
  color: var(--text-primary);
}

.template-card--studio .template-card__desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.48;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tpl-card__foot {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-default, rgba(148, 163, 184, 0.18));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.tpl-card__sec-info {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.tpl-card__actions {
  display: flex;
  gap: 6px;
}

.tpl-card__preview-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.35));
  background: transparent;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.tpl-card__preview-btn:hover {
  border-color: var(--accent, #ea580c);
  color: var(--accent, #ea580c);
}

.template-card--studio .template-card__use {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.tpl-studio-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 20px;
  border-radius: 14px;
  border: 1px dashed var(--border-default, rgba(148, 163, 184, 0.35));
  color: var(--text-muted);
  font-size: 14px;
}

/* PC / 모바일 전환 미리보기 모달 */
.tpl-preview-dialog {
  width: min(940px, 94vw);
  max-height: 90vh;
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.3));
  border-radius: 18px;
  padding: 0;
  background: var(--bg-surface, #ffffff);
  color: var(--text-primary);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.tpl-preview-dialog::backdrop {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
}

.tpl-preview-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default, rgba(148, 163, 184, 0.22));
  flex-wrap: wrap;
}

.tpl-preview-dialog__title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
}

.tpl-preview-dialog__badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tpl-preview-dialog__head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tpl-preview-vp-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--bg-surface-subtle, rgba(148, 163, 184, 0.14));
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.24));
}

.tpl-vp-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.tpl-vp-btn.is-active {
  background: var(--bg-surface, #ffffff);
  color: var(--accent, #ea580c);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
}

.tpl-preview-dialog__close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.3));
  background: transparent;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
}

.tpl-preview-dialog__body {
  padding: 18px 20px;
  display: grid;
  gap: 14px;
  max-height: calc(90vh - 150px);
  overflow-y: auto;
}

.tpl-preview-dialog__stage {
  background: var(--bg-surface-subtle, #f1f5f9);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  max-height: 480px;
  overflow-y: auto;
}

.tpl-preview-dialog__stage canvas {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.14);
}

.tpl-preview-dialog__stage.is-mobile canvas {
  width: 375px !important;
  max-width: 100%;
  border: 0;
  border-radius: 0;
}

.tpl-preview-block-stack {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.tpl-preview-dialog__stage.is-mobile .tpl-preview-block-stack {
  width: 391px;
  max-width: 100%;
  padding: 8px;
  background: #1e293b;
  border-radius: 26px;
  gap: 6px;
}

.tpl-preview-block-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.tpl-preview-block-divider {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 700;
}

html[data-theme="dark"] .tpl-preview-block-divider {
  background: rgba(255, 255, 255, 0.09);
}

.tpl-preview-dialog__stage.is-mobile .tpl-preview-block-divider {
  background: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  font-size: 11px;
}

.tpl-preview-dialog__specs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 720px) {
  .tpl-preview-dialog__specs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.tpl-preview-dialog__spec-box {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-surface-subtle, rgba(148, 163, 184, 0.08));
  border: 1px solid var(--border-default, rgba(148, 163, 184, 0.2));
  display: grid;
  gap: 3px;
}

.tpl-preview-dialog__spec-label {
  font-size: 11px;
  color: var(--text-muted);
}

.tpl-preview-dialog__spec-box strong {
  font-size: 13px;
  color: var(--text-primary);
}

.tpl-preview-dialog__desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.58;
  color: var(--text-muted);
}

.tpl-preview-dialog__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-default, rgba(148, 163, 184, 0.22));
}
