/* Danger View */
.zt-danger-view { padding: 40px 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; text-align: center; animation: slideUpFade 0.25s ease-out; }
.zt-danger-icon { width: 64px; height: 64px; background: rgba(239, 68, 68, 0.12); color: #ef4444; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 24px; font-size: 28px; }
.zt-danger-title { font-size: 20px; font-weight: 700; margin-bottom: 12px; color: var(--zt-text); }
.zt-danger-text { font-size: 15px; color: #64748b; margin-bottom: 36px; line-height: 1.5; }
.zt-btn-danger {
  flex: 1;
  padding: 14px;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid rgba(239, 68, 68, 0.28);
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
}
.zt-btn-danger:hover { background: #1e293b; border-color: rgba(239, 68, 68, 0.45); }

/* Help Overlay */
.zt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s;
}

.zt-overlay h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--zt-text);
  margin-bottom: 24px;
}

.zt-overlay p {
  font-size: 14px;
  color: #475569;
  line-height: 1.6;
  margin-bottom: 20px;
}

.zt-overlay code {
  background: rgba(15, 23, 42, 0.08);
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--zt-font-mono);
  font-size: 13px;
}

.zt-overlay-actions {
  margin-top: auto;
}

/* Template Preview */
.zt-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.zt-preview-overlay,
.zt-preview-overlay * {
  font-family: var(--zt-font);
  box-sizing: border-box;
}
.zt-preview-overlay.show { opacity: 1; }
.zt-preview-card {
  width: 820px;
  max-width: 94vw;
  height: 72vh;
  max-height: 86vh;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 24px 50px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px);
  transition: width 0.2s ease, height 0.2s ease, transform 0.2s ease, border-radius 0.2s ease;
}
.zt-preview-overlay.fullscreen .zt-preview-card {
  width: 96vw;
  height: 92vh;
  max-width: none;
  max-height: none;
  border-radius: 20px;
  transform: translateY(0);
}
.zt-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.9);
}
.zt-preview-title { font-size: 16px; font-weight: 700; color: #0f172a; }
.zt-preview-title-row { display: flex; align-items: center; gap: 8px; }
.zt-preview-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
  border: 1px solid rgba(14, 165, 233, 0.3);
}
.zt-preview-badge.is-example {
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
  border-color: rgba(14, 165, 233, 0.25);
}
.zt-preview-badge.is-custom {
  background: rgba(34, 197, 94, 0.12);
  color: #166534;
  border-color: rgba(22, 101, 52, 0.25);
}
.zt-preview-badge.locked {
  background: rgba(15, 23, 42, 0.08);
  color: #64748b;
  border-color: rgba(15, 23, 42, 0.18);
}
.zt-preview-subject { font-size: 12px; color: #64748b; margin-top: 2px; }
.zt-preview-actions { display: flex; gap: 8px; align-items: center; }
.zt-preview-body {
  flex: 1;
  overflow: auto;
  padding: 24px;
  background: #eef2f7;
}
.zt-preview-email {
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  padding: 24px;
  max-width: 820px;
  margin: 0 auto;
  overflow-x: auto;
  width: 100%;
  box-sizing: border-box;
}
.zt-preview-email * {
  box-sizing: border-box;
}
.zt-preview-email table {
  width: 100% !important;
  max-width: 100% !important;
  table-layout: fixed;
}
.zt-preview-email img {
  max-width: 100%;
  height: auto;
}
.zt-preview-email td,
.zt-preview-email th {
  box-sizing: border-box;
}
@media (max-width: 640px) {
  .zt-preview-overlay {
    align-items: stretch;
    justify-content: stretch;
  }

  .zt-preview-card,
  .zt-preview-overlay.fullscreen .zt-preview-card {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    transform: none;
  }

  .zt-preview-body {
    padding: 0;
    background: #ffffff;
  }

  .zt-preview-email {
    padding: 14px 10px;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
  }

  .zt-preview-email .mp-stack {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .zt-preview-email .mp-fluid {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
  }

  .zt-preview-header {
    padding: 10px 12px;
  }

  .zt-preview-title {
    font-size: 14px;
    line-height: 1.2;
  }

  .zt-preview-subject {
    display: none;
  }
}
.zt-preview-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(248, 250, 252, 0.9);
}
.zt-preview-footer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.zt-preview-more {
  position: relative;
}
.zt-preview-more > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.zt-preview-more > summary::-webkit-details-marker {
  display: none;
}
.zt-preview-more-menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 4;
  min-width: 156px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #ffffff;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.zt-preview-more:not([open]) .zt-preview-more-menu {
  display: none;
}
.zt-preview-more-menu button {
  width: 100%;
  justify-content: flex-start;
  box-shadow: none;
}
.zt-preview-footer-actions:last-child {
  margin-left: auto;
}
.zt-preview-footer .zt-btn-secondary,
.zt-preview-footer .zt-btn-cancel,
.zt-preview-footer .zt-btn-save {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.zt-preview-footer .zt-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.zt-preview-footer .zt-btn-icon svg {
  display: block;
}

@media (max-width: 640px) {
  .zt-preview-footer {
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }

  .zt-preview-footer-actions {
    gap: 8px;
    flex-wrap: nowrap;
  }

  .zt-preview-primary-actions {
    flex: 1;
  }

  .zt-preview-primary-actions .zt-btn-save,
  .zt-preview-primary-actions .zt-btn-secondary {
    width: 100%;
    justify-content: center;
  }

  .zt-preview-footer .zt-btn-secondary,
  .zt-preview-footer .zt-btn-cancel,
  .zt-preview-footer .zt-btn-save,
  .zt-preview-more > summary {
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 12px;
    white-space: nowrap;
  }

  .zt-preview-more-menu {
    left: auto;
    right: 0;
  }
}

/* Variable Form */
.zt-var-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.zt-var-row:last-child { margin-bottom: 0; }
.zt-input-var { width: 100%; }

.zt-vars-view { min-height: 0; }
.zt-vars-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  margin-bottom: 14px;
}
.zt-vars-section { margin-bottom: 16px; }
.zt-vars-section:last-child { margin-bottom: 0; }
.zt-vars-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 10px;
}
.zt-vars-toggle {
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #f8fafc;
  color: #0f172a;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 10px;
  transition: background 0.2s, border 0.2s;
}
.zt-vars-toggle:hover { background: #ffffff; border-color: rgba(15, 23, 42, 0.2); }
.zt-vars-toggle-icon { font-size: 12px; }
.zt-vars-optional.is-collapsed { display: none; }
.zt-var-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--zt-text);
}
.zt-var-name {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  font-family: var(--zt-font-mono);
}
.zt-var-meta {
  font-size: 11px;
  color: #94a3b8;
}

.zt-btn-secondary {
  flex: 1;
  padding: 14px;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, border 0.2s;
}
.zt-btn-secondary:hover {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.2);
}
.zt-btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Billing View */
.zt-billing-card {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.zt-billing-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: #475569; }
.zt-billing-row strong { color: #0f172a; font-weight: 700; }
.zt-billing-note { font-size: 12px; color: #94a3b8; margin-top: 12px; line-height: 1.4; }

.zt-link-btn {
  background: none;
  border: none;
  color: var(--zt-primary-strong);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.zt-link-btn:hover { text-decoration: underline; }

.zt-upgrade-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 0;
}
