.tpl-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.75rem 1.25rem;
}

@media (min-width: 520px) {
  .tpl-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem 1.5rem;
  }
}

@media (min-width: 900px) {
  .tpl-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2.25rem 1.75rem;
  }
}

@media (min-width: 1200px) {
  .tpl-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.tpl-card {
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.tpl-card:hover {
  transform: translateY(-5px);
}

.tpl-card:hover .tpl-frame {
  box-shadow: 0 16px 40px rgba(124, 106, 239, 0.16);
  border-color: #c4b5fd;
}

.tpl-card.is-active .tpl-frame {
  border-color: #7c6aef;
  box-shadow: 0 0 0 2px rgba(124, 106, 239, 0.35);
}

.tpl-frame {
  position: relative;
  background: linear-gradient(168deg, #e8ebf0 0%, #dfe3ea 100%);
  border-radius: 1rem;
  border: 1px solid #dde1e8;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.07);
  transition: box-shadow 0.22s, border-color 0.22s;
  padding: 0.875rem;
  min-height: 340px;
  aspect-ratio: 4 / 5;
}

@media (min-width: 900px) {
  .tpl-frame {
    min-height: 380px;
    padding: 1rem;
  }
}

.tpl-name {
  margin-top: 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tpl-card.is-active .tpl-name {
  color: #7c6aef;
  font-weight: 600;
}

.tpl-active-badge {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  width: 1.5rem;
  height: 1.5rem;
  background: #7c6aef;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.625rem;
  z-index: 4;
  box-shadow: 0 2px 8px rgba(124, 106, 239, 0.45);
}

.tpl-hover-mask {
  position: absolute;
  inset: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.42);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  border-radius: 0.25rem;
  z-index: 3;
  pointer-events: none;
}

@media (min-width: 900px) {
  .tpl-hover-mask {
    inset: 1rem;
  }
}

.tpl-card:hover .tpl-hover-mask,
.tpl-card:focus-visible .tpl-hover-mask,
.tpl-card:active .tpl-hover-mask {
  opacity: 1;
  visibility: visible;
}

.tpl-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.35rem;
  background: #fff;
  color: #7c6aef;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 9999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  letter-spacing: 0.02em;
}

.tpl-preview {
  height: 100%;
  overflow: hidden;
  position: relative;
  border-radius: 0.25rem;
  background: #fff;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.08),
    0 6px 20px rgba(0, 0, 0, 0.1);
}

.tpl-preview::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18%;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
  pointer-events: none;
  z-index: 1;
}

.r-doc {
  height: 100%;
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: #1f2937;
  line-height: 1.45;
  overflow: hidden;
  font-size: 10.5px;
}

.r-doc * {
  box-sizing: border-box;
}

.r-inner {
  padding: 12px 14px 16px;
}

.r-tac {
  text-align: center;
}

.r-name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  letter-spacing: 0.02em;
  line-height: 1.25;
}

.r-meta {
  margin: 3px 0 0;
  font-size: 9.5px;
  color: #6b7280;
  line-height: 1.4;
}

.r-summary {
  margin: 6px 0 0;
  font-size: 8.5px;
  color: #6b7280;
  line-height: 1.5;
}

.r-work {
  margin-top: 8px;
}

.r-work-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  font-size: 10px;
}

.r-work-row strong {
  color: #111827;
  font-weight: 600;
}

.r-work-row span {
  color: #9ca3af;
  font-size: 8.5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.r-work-role {
  font-size: 9px;
  color: #6b7280;
  margin-top: 1px;
}

.r-work-bullet {
  margin: 4px 0 0;
  font-size: 9px;
  color: #4b5563;
  line-height: 1.45;
  padding-left: 8px;
  position: relative;
}

.r-work-bullet::before {
  content: '·';
  position: absolute;
  left: 0;
  color: #9ca3af;
}

.r-block {
  margin-top: 8px;
}

.r-block-title {
  margin: 0 0 3px;
  font-size: 9.5px;
  font-weight: 700;
  color: #374151;
}

.r-block-line {
  margin: 0;
  font-size: 9px;
  color: #6b7280;
  line-height: 1.4;
}

.r-photo {
  border-radius: 50%;
  background: linear-gradient(145deg, #e9d5ff, #c4b5fd);
  flex-shrink: 0;
}

.r-photo-sm {
  width: 22px;
  height: 22px;
}

.r-photo-lg {
  width: 28px;
  height: 28px;
  margin: 0 auto 6px;
}

.r-photo-white {
  width: 24px;
  height: 24px;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.r-divider {
  height: 1px;
  background: #111827;
  margin: 8px 0;
}

.r-divider-double {
  height: 3px;
  border-top: 1px solid #111827;
  border-bottom: 1px solid #111827;
  margin: 8px auto;
  width: 65%;
}

.r-dot {
  width: 20px;
  height: 2px;
  background: #10b981;
  margin: 6px auto 10px;
}

.r-style-minimal .r-accent {
  height: 4px;
  background: #7c6aef;
}

.r-style-minimal .r-block-title {
  color: #7c6aef;
  border-bottom: 1px solid #ede9fe;
  padding-bottom: 2px;
}

.r-style-executive {
  border-left: 3px solid #111827;
}

.r-style-executive .r-name {
  font-family: Georgia, 'Noto Serif SC', serif;
}

.r-style-creative .r-hero {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
}

.r-style-creative .r-hero .r-photo {
  width: 26px;
  height: 26px;
  background: rgba(255, 255, 255, 0.35);
}

.r-style-creative .r-hero .r-name {
  color: #fff;
  font-size: 14px;
}

.r-style-creative .r-hero .r-meta {
  color: rgba(255, 255, 255, 0.88);
}

.r-style-creative .r-block-title {
  color: #6366f1;
}

.r-style-academic .r-name {
  color: #065f46;
}

.r-style-academic .r-summary,
.r-style-intern .r-summary,
.r-style-classic .r-summary,
.r-style-teacher .r-summary {
  text-align: center;
}

.r-style-academic .r-block-title {
  color: #059669;
}

.r-style-column {
  display: grid;
  grid-template-columns: 34% 66%;
  height: 100%;
}

.r-style-column .r-aside {
  background: linear-gradient(180deg, #0891b2, #0e7490);
  color: #fff;
  padding: 12px 8px;
  text-align: center;
}

.r-style-column .r-aside .r-name {
  font-size: 11px;
  color: #fff;
}

.r-style-column .r-aside-label {
  font-size: 8.5px;
  opacity: 0.92;
  margin: 2px 0 8px;
}

.r-style-column .r-aside-info {
  font-size: 8px;
  line-height: 1.5;
  opacity: 0.9;
  margin: 0;
}

.r-style-column .r-main {
  padding: 12px 10px;
}

.r-style-column .r-block-title {
  color: #0891b2;
}

.r-style-timeline .r-tl {
  margin-top: 8px;
  padding-left: 10px;
  border-left: 2px solid #fcd34d;
}

.r-style-timeline .r-tl-node {
  position: relative;
  margin-bottom: 10px;
  padding-left: 4px;
}

.r-style-timeline .r-tl-node::before {
  content: '';
  position: absolute;
  left: -13px;
  top: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 1px #fcd34d;
}

.r-style-timeline .r-tl-node span {
  display: block;
  font-size: 8px;
  color: #d97706;
}

.r-style-timeline .r-tl-node strong {
  display: block;
  font-size: 9.5px;
  color: #111827;
  margin-top: 1px;
}

.r-style-timeline .r-tl-node p {
  margin: 2px 0 0;
  font-size: 8.5px;
  color: #6b7280;
}

.r-style-classic .r-name {
  font-family: Georgia, 'Noto Serif SC', serif;
}

.r-style-classic .r-meta {
  letter-spacing: 0.05em;
}

.r-style-compact {
  padding: 10px 12px;
}

.r-style-compact .r-compact-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid #7c6aef;
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.r-style-compact .r-compact-head .r-name {
  font-size: 13px;
}

.r-style-compact .r-compact-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.r-style-compact .r-work,
.r-style-compact .r-block {
  margin-top: 0;
}

.r-style-compact .r-work-row,
.r-style-compact .r-work-role,
.r-style-compact .r-work-bullet,
.r-style-compact .r-block-line {
  font-size: 8px;
}

.r-style-elegant .r-elegant-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.r-style-elegant .r-name {
  font-family: Georgia, 'Noto Serif SC', serif;
}

.r-style-elegant .r-dash {
  margin: 8px 0 4px;
  font-size: 9px;
  color: #a8a29e;
  font-family: Georgia, serif;
}

.r-style-split {
  padding: 12px 14px;
}

.r-style-split .r-split-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid #111827;
  padding-bottom: 4px;
  margin-bottom: 8px;
}

.r-style-split .r-split-top .r-name {
  font-size: 13px;
}

.r-style-split .r-label {
  display: inline-block;
  background: #111827;
  color: #fff;
  font-size: 8px;
  font-weight: 600;
  padding: 2px 6px;
  margin: 6px 0 4px;
}

.r-style-dev {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px 14px;
}

.r-style-dev .r-prompt {
  margin: 0 0 4px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 8px;
  color: #22d3ee;
}

.r-style-dev .r-name {
  font-size: 13px;
  color: #22d3ee;
  font-family: 'SF Mono', Menlo, monospace;
}

.r-style-dev .r-meta {
  color: #94a3b8;
  font-family: 'SF Mono', Menlo, monospace;
}

.r-style-dev .r-summary {
  color: #94a3b8;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 8px;
}

.r-style-dev .r-block-title {
  color: #22d3ee;
  font-family: 'SF Mono', Menlo, monospace;
}

.r-style-dev .r-block-line {
  color: #cbd5e1;
  font-family: 'SF Mono', Menlo, monospace;
}

.r-style-fresh {
  background: #f9fafb;
}

.r-style-fresh .r-name {
  color: #7c6aef;
}

.r-style-fresh .r-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 8px 10px;
  margin-top: 8px;
}

.r-style-fresh .r-card .r-work,
.r-style-fresh .r-card .r-block {
  margin-top: 0;
}

.r-style-fresh .r-block-title {
  color: #7c6aef;
}

.r-style-bold .r-bold-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #dc2626, #ef4444);
  color: #fff;
}

.r-style-bold .r-bold-banner .r-name {
  color: #fff;
  font-size: 14px;
}

.r-style-bold .r-bold-banner .r-meta {
  color: rgba(255, 255, 255, 0.9);
}

.r-style-bold .r-block-title {
  color: #dc2626;
}

.r-style-intern .r-name { color: #2563eb; }
.r-style-intern .r-dot { background: #3b82f6; }
.r-style-intern .r-block-title { color: #2563eb; }

.r-style-product .r-accent { height: 4px; background: #f97316; }
.r-style-product .r-block-title { color: #ea580c; border-bottom: 1px solid #ffedd5; padding-bottom: 2px; }

.r-style-fe .r-fe-bar { height: 4px; background: #0ea5e9; }
.r-style-fe .r-block-title { color: #0284c7; }

.r-style-be .r-aside-dark {
  background: linear-gradient(180deg, #1e293b, #0f172a);
}

.r-style-be .r-block-title { color: #334155; }

.r-style-teacher .r-name { font-family: Georgia, 'Noto Serif SC', serif; color: #78350f; }
.r-style-teacher .r-block-title { color: #92400e; }

.r-style-medical .r-block-title { color: #0d9488; }
.r-style-medical .r-photo-sm { background: linear-gradient(145deg, #99f6e4, #5eead4); }

.r-style-startup .r-hero-warm {
  background: linear-gradient(135deg, #f97316, #fb923c);
}

.r-style-startup .r-hero-warm .r-photo { background: rgba(255,255,255,0.35); }
.r-style-startup .r-hero-warm .r-name { color: #fff; font-size: 14px; }
.r-style-startup .r-hero-warm .r-meta { color: rgba(255,255,255,0.9); }
.r-style-startup .r-block-title { color: #ea580c; }

.r-style-consultant {
  border-left: 3px solid #1e3a5f;
}

.r-style-consultant .r-name { font-family: Georgia, 'Noto Serif SC', serif; }
.r-style-consultant .r-divider { background: #1e3a5f; }
.r-style-consultant .r-block-title { color: #1e3a5f; }

.tpl-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: #9ca3af;
  font-size: 0.875rem;
}
