.msgd-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 360px);
  gap: 1rem;
  align-items: start;
  min-width: 0;
}

.msgd-card {
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  background: #fff;
  padding: 1rem;
  display: grid;
  gap: 1rem;
  box-shadow: 0 18px 44px rgba(17, 24, 39, .05);
  min-width: 0;
}

.msgd-card--sticky {
  position: sticky;
  top: 1rem;
}

.msgd-editor-shell {
  border: 1px solid #d1d5db;
  border-radius: .7rem;
  background: #fff;
  padding: .5rem;
  display: grid;
  gap: .5rem;
  min-width: 0;
}

.msgd-editor-tools {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: .5rem;
}

.msgd-token-menu {
  position: relative;
  min-width: 0;
}

.msgd-token-menu > summary {
  list-style: none;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 999px;
  padding: .38rem .72rem;
  font-size: .78rem;
  line-height: 1.1;
  cursor: pointer;
  transition: all .12s ease;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  user-select: none;
}

.msgd-token-menu > summary::-webkit-details-marker {
  display: none;
}

.msgd-token-menu[open] > summary,
.msgd-token-menu > summary:hover {
  border-color: #60a5fa;
  background: #eff6ff;
  color: #1d4ed8;
}

.msgd-token-menu__panel {
  position: absolute;
  top: calc(100% + .4rem);
  left: 0;
  z-index: 20;
  min-width: 260px;
  max-width: min(340px, 90vw);
  border: 1px solid #dbe4f0;
  border-radius: .95rem;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .12);
  padding: .45rem;
  display: grid;
  gap: .25rem;
}

.msgd-token-menu__label {
  padding: .35rem .55rem .15rem;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #94a3b8;
}

.msgd-token-option {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: .7rem;
  padding: .52rem .62rem;
  text-align: left;
  display: grid;
  gap: .1rem;
}

.msgd-token-option:hover {
  background: #f8fafc;
}

.msgd-token-option strong {
  font-size: .85rem;
  color: #0f172a;
}

.msgd-token-option span {
  font-size: .74rem;
  color: #64748b;
}

.msgd-editor {
  min-height: 68px;
  outline: none;
  border: 0;
  white-space: pre-wrap;
  line-height: 1.45;
  font-size: .92rem;
  color: #111827;
  overflow-wrap: anywhere;
}

.msgd-editor.is-body {
  min-height: 220px;
}

.msgd-token {
  display: inline-flex;
  align-items: center;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: .08rem .45rem;
  margin: .04rem .12rem .04rem 0;
  font-size: .75rem;
  line-height: 1.25;
  vertical-align: baseline;
  user-select: none;
}

.msgd-hidden-value {
  display: none !important;
}

.msgd-preview {
  display: grid;
  gap: .85rem;
  min-width: 0;
}

.msgd-preview__mail {
  border: 1px solid #fed7aa;
  border-radius: 1rem;
  background: #fff7ed;
  padding: 1rem;
  display: grid;
  gap: .75rem;
  min-width: 0;
}

.msgd-preview__label {
  color: #9a3412;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: .72rem;
  font-weight: 800;
}

.msgd-preview__subject {
  font-weight: 800;
  color: #111827;
  overflow-wrap: anywhere;
}

.msgd-preview__body {
  white-space: pre-wrap;
  color: #374151;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.msgd-back {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  text-decoration: none;
}

@media (max-width: 1100px) {
  .msgd-layout {
    grid-template-columns: 1fr;
  }

  .msgd-card--sticky {
    position: static;
  }
}

@media (max-width: 560px) {
  .msgd-token-menu,
  .msgd-token-menu > summary {
    width: 100%;
  }

  .msgd-token-menu > summary {
    justify-content: center;
    min-height: 44px;
  }

  .msgd-token-menu__panel {
    left: 0;
    right: 0;
    min-width: 0;
    max-width: calc(100vw - 2rem);
  }
}
