:root {
  --template-ink: #121214;
  --template-muted: #626469;
  --template-border: #e5e7eb;
  --template-soft: #f6f7f9;
  --template-blue: #2563eb;
  --template-blue-dark: #1d4ed8;
}

html {
  scroll-padding-top: 92px;
}

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

.template-empty-state {
  margin-top: 24px;
  padding: 64px 20px;
  border: 1px dashed #d1d5db;
  border-radius: 20px;
  background: #fbfbfc;
  text-align: center;
}

.template-empty-state > span {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: #f3f4f6;
  color: #6b7280;
}

.template-empty-state h3 {
  margin-top: 13px;
  color: var(--template-ink);
  font-size: 16px;
  font-weight: 850;
}

.template-empty-state p {
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
}

.template-empty-state button {
  margin-top: 15px;
  color: var(--template-blue);
  font-size: 11px;
  font-weight: 850;
}

.template-preview-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.template-preview-modal.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.template-preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 18, 20, 0.64);
  backdrop-filter: blur(8px);
}

.template-preview-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(860px, calc(100vw - 32px));
  height: min(790px, calc(100dvh - 32px));
  grid-template-columns: minmax(0, 500px) 360px;
  overflow: hidden;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
  transform: translateY(8px) scale(0.99);
  transition: transform 180ms ease;
}

.template-preview-modal.is-open .template-preview-dialog {
  transform: translateY(0) scale(1);
}

.template-modal-visual {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #e5e7eb;
  background: #f3f4f6;
}

.template-carousel {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.template-modal-slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  visibility: hidden;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms ease;
}

.template-modal-slide.is-active {
  visibility: visible;
  opacity: 1;
  transform: translateX(0);
}

.template-modal-paper {
  position: relative;
  width: min(72%, 445px);
  aspect-ratio: 210 / 297;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 16px 45px rgba(15, 23, 42, 0.16);
}

.template-modal-slide-image {
  padding: 0;
}

.template-carousel-dots {
  display: flex;
  align-items: center;
  gap: 5px;
}

.template-carousel-dots button {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #b8bec8;
  transition: width 160ms ease, background-color 160ms ease;
}

.template-carousel-dots button.is-active {
  width: 18px;
  background: var(--template-blue);
}

.template-handoff-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  display: flex;
  width: min(360px, calc(100vw - 32px));
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border: 1px solid #bbf7d0;
  border-radius: 14px;
  background: #f0fdf4;
  color: #166534;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.16);
  visibility: hidden;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 170ms ease, transform 170ms ease, visibility 170ms ease;
}

.template-handoff-toast.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

.template-handoff-toast > span {
  font-size: 19px;
}

.template-handoff-toast strong {
  display: block;
  font-size: 11px;
  font-weight: 850;
}

.template-handoff-toast p {
  margin-top: 2px;
  font-size: 9px;
  line-height: 1.4;
}

@media (max-width: 900px) {
  .template-preview-dialog {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(440px, 1fr) auto;
    overflow-y: auto;
  }

  .template-modal-visual {
    min-height: 440px;
    border-right: 0;
    border-bottom: 1px solid #e5e7eb;
  }

}

@media (max-width: 720px) {
  .template-preview-dialog {
    width: calc(100vw - 32px);
    height: calc(100dvh - 32px);
    grid-template-rows: minmax(410px, 1fr) auto;
    border-radius: 18px;
  }

  .template-modal-visual {
    min-height: 410px;
  }

  .template-modal-slide {
    padding: 22px;
  }

  .template-modal-paper {
    width: min(68%, 300px);
  }

}

@media (hover: none), (pointer: coarse) {
  .template-card-actions {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .template-card-paper,
  .template-card-actions,
  .template-modal-slide,
  .template-preview-dialog,
  .template-preview-modal,
  .template-handoff-toast {
    transition: none !important;
  }
}
