.template-builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  gap: 16px;
  align-items: start;
}

.template-editor-panel,
.email-preview-panel {
  min-width: 0;
}

.template-card {
  align-content: start;
}

/* Real, distinct thumbnails (live review, 2026-10-07) -- previously
   three identical grey bars on every card, with no way to tell one
   template/starter apart from another at a glance. Each starter gets
   its own real glyph + accent color (see templates-list-widget.js's
   STARTER_THUMBS); saved templates get a generic mail glyph tinted by
   their real status instead. */
.template-card__thumb {
  display: grid;
  place-items: center;
  min-height: 92px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

.template-card__glyph {
  font-size: 32px;
  line-height: 1;
}

.template-card__thumb--amber { background: #fffbeb; border-color: #fde68a; }
.template-card__thumb--blue { background: #eff6ff; border-color: #bfdbfe; }
.template-card__thumb--green { background: #f0fdf4; border-color: #bbf7d0; }
.template-card__thumb--purple { background: #faf5ff; border-color: #e9d5ff; }
.template-card__thumb--gold { background: #fefce8; border-color: #fef08a; }
.template-card__thumb--teal { background: #f0fdfa; border-color: #99f6e4; }
.template-card__thumb--pink { background: #fdf2f8; border-color: #fbcfe8; }
.template-card__thumb--red { background: #fef2f2; border-color: #fecaca; }
.template-card__thumb--success { background: #f0fdf4; border-color: #bbf7d0; }
.template-card__thumb--neutral { background: #f8fafc; }

.template-block-stack {
  display: grid;
  gap: 12px;
}

.template-block {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.template-block legend {
  padding: 0 6px;
}

.template-block__handle {
  display: inline-block;
  margin-inline-end: 8px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0;
}

.email-preview-shell {
  box-sizing: border-box;
  inline-size: 100%;
  max-inline-size: 680px;
  margin-inline: auto;
  padding: 16px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #eef2f7;
}

.email-preview-shell iframe {
  box-sizing: border-box;
  display: block;
  inline-size: 100%;
  max-inline-size: 600px;
  block-size: 620px;
  margin-inline: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.08);
  background: #fff;
  transition: max-inline-size 0.15s ease;
}

/* Real, working toggle (live review, 2026-10-07) -- a realistic phone
   email-client width, not an arbitrary shrink. The shell itself also
   narrows so the grey margin stays proportional instead of the white
   card looking lost in a wide, mostly-empty background. */
.email-preview-shell--mobile {
  max-inline-size: 420px;
}

.email-preview-shell--mobile iframe {
  max-inline-size: 375px;
}

.segmented-control {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segmented-control button {
  min-inline-size: 72px;
  border: 0;
  border-radius: 6px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.segmented-control button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.12);
}

.templates-product-picker-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.templates-product-picker-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-soft);
}

.templates-product-picker-media {
  inline-size: 48px;
  block-size: 48px;
  border-radius: 8px;
  overflow: hidden;
  background: #e5e7eb;
}

.templates-product-picker-media img,
.templates-product-picker-media span {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

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

@media (max-width: 640px) {
  .templates-product-picker-row {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .templates-product-picker-row .text-button {
    grid-column: 2;
    justify-self: start;
  }
}
