:root {
  --bg: #0a0a0a;
  --bg-card: #141414;
  --bg-card-hover: #1a1a1a;
  --surface: #111111;
  --text: #f5f5f5;
  --text-muted: #9ca3af;
  --red: #e60012;
  --red-bright: #ff1a2e;
  --red-glow: rgba(230, 0, 18, 0.55);
  --red-dim: rgba(230, 0, 18, 0.15);
  --border: rgba(255, 255, 255, 0.08);
  --border-red: rgba(230, 0, 18, 0.45);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-red: 0 0 20px rgba(230, 0, 18, 0.35), 0 0 40px rgba(230, 0, 18, 0.15);
  --radius: 10px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  width: min(1200px, 100% - 32px);
  margin: 0 auto;
  position: relative;
}

/* ===== Header Banner ===== */
.site-header {
  position: relative;
  margin-bottom: 0;
}

.hero-banner {
  position: relative;
  width: 100%;
  height: 250px;
  overflow: hidden;
  background: #0a0a0a;
}

.hero-img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  object-position: center center;
  display: block;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(10, 10, 10, 0.05) 0%,
    rgba(10, 10, 10, 0.45) 75%,
    var(--bg) 100%
  );
}

/* ===== Search ===== */
.search-box {
  position: relative;
  width: 260px;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}

#searchInput {
  width: 100%;
  padding: 12px 16px 12px 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#searchInput::placeholder {
  color: #555;
}

#searchInput:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-dim), var(--shadow-red);
}

/* ===== Stats ===== */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.stats-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.filter-hint {
  color: var(--red-bright);
}

/* ===== Template Grid ===== */
.template-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  column-gap: 20px;
  row-gap: 40px;
  padding-bottom: 24px;
}

.template-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.template-card:hover {
  transform: translateY(-4px) translateZ(0);
  border-color: var(--border-red);
  box-shadow: var(--shadow-red);
}

.card-image-wrap {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #1c1c1c;
  overflow: hidden;
  line-height: 0;
  flex-shrink: 0;
}

.card-image-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 60%, rgba(10, 10, 10, 0.7) 100%);
  pointer-events: none;
  z-index: 1;
}

.card-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  vertical-align: top;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.card-body {
  position: relative;
  z-index: 2;
  margin-top: -2px;
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
  background: var(--bg-card);
  transition: background 0.25s ease;
}

.template-card:hover .card-body {
  background: var(--bg-card-hover);
}

.template-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 4px;
  letter-spacing: 0.06em;
  box-shadow: 0 0 12px var(--red-glow);
  white-space: nowrap;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--text);
}

.card-actions {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}

.card-actions .btn-primary {
  flex: 0 0 30%;
  max-width: 92px;
}

.card-actions .template-badge {
  margin-left: auto;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-sm {
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}

.btn-primary {
  background: var(--red);
  color: #fff;
  border: 1px solid var(--red);
}

.btn-primary:hover {
  background: var(--red-bright);
  box-shadow: 0 0 16px var(--red-glow);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-red);
}

.btn-secondary:hover {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red-bright);
  box-shadow: 0 0 12px var(--red-dim);
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
}

.empty-state p {
  margin-bottom: 16px;
  font-size: 1.05rem;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 48px;
}

.page-numbers {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.page-btn:hover:not(:disabled):not(.is-active) {
  border-color: var(--border-red);
  color: var(--red-bright);
}

.page-btn.is-active {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-num {
  min-width: 34px;
  padding: 6px 8px;
  text-align: center;
}

.page-info {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-left: 8px;
}

/* ===== Footer ===== */
.site-footer {
  margin-top: auto;
  padding: 32px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

@media (max-width: 900px) {
  .template-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .hero-banner {
    height: 190px;
  }

  .hero-img {
    height: 190px;
  }

  .stats-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    width: 100%;
  }

  .template-grid {
    grid-template-columns: 1fr;
    column-gap: 16px;
    row-gap: 36px;
  }
}
