/* Emails visualizer */

.emails-loading,
.emails-empty-state {
  min-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: var(--ink-muted);
  text-align: center;
}

.emails-empty-state i {
  font-size: 28px;
  color: #8a6d2f;
}

.emails-empty-state strong {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  font-weight: 500;
  color: var(--ink);
}

.emails-empty-state span {
  max-width: 420px;
  font-size: 13px;
  line-height: 1.55;
}

.emails-empty-state button {
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--ink);
  color: var(--card-bg);
  font: 600 12px 'Inter', sans-serif;
  cursor: pointer;
}

/* Project nav scrolls horizontally on desktop instead of wrapping to a second
   row (canonical .pillbar wraps by default). Keep the scrollbar visible — the
   user wants an explicit horizontal scroll affordance here. */
.emails-surface .surface-nav > .pillbar {
  display: flex;
  width: 100%;
  max-width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.emails-surface .surface-nav > .pillbar > .pill {
  flex: 0 0 auto;
}

/* Detail region: master-detail (template list | preview) inside the surface body.
   Project navigation lives in the surface-nav pillbar above; filters/search in
   the surface-toolbar. */
.emails-detail {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(0, 1fr);
  min-height: calc(100vh - 230px);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: color-mix(in srgb, var(--card-bg) 84%, var(--bg) 16%);
}

.emails-template-list {
  min-width: 0;
  border-right: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 78%, var(--card-bg) 22%);
}

.emails-surface-label,
.emails-template-kicker,
.emails-editor-title span,
.emails-tag-group > div {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.emails-template-row,
.emails-device-toggle button,
.emails-save-btn,
.emails-tag-group button {
  font-family: 'Inter', sans-serif;
}

/* Toolbar count (surface-toolbar context) */
.emails-toolbar-count {
  font: 600 12px 'Inter', sans-serif;
  color: var(--ink-muted);
  white-space: nowrap;
}
.emails-toolbar-count strong { color: var(--ink); }

.emails-warning-box {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid #eadfca;
  border-radius: 8px;
  background: #fff8ea;
  color: #6f5c25;
  font-size: 12px;
  line-height: 1.45;
}

.emails-template-list {
  display: flex;
  flex-direction: column;
  padding: 18px 0 18px 18px;
  overflow: hidden;
}

.emails-search {
  width: 240px;
  max-width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--ink-light);
}

.emails-search input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font: 500 13px 'Inter', sans-serif;
}

.emails-search input::placeholder {
  color: var(--ink-light);
}

.emails-journey-map {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding-right: 18px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.emails-journey-map::-webkit-scrollbar { height: 0; display: none; }

.emails-journey-map button {
  flex: 0 0 auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--ink-muted);
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}

.emails-journey-map button.active {
  border-color: #c9b57d;
  background: color-mix(in srgb, var(--card-bg) 90%, #fff8e1 10%);
  color: var(--ink);
}

.emails-journey-map span {
  font: 700 11px 'Inter', sans-serif;
}

.emails-journey-map strong {
  color: var(--ink);
  font: 700 11px 'Inter', sans-serif;
}

.emails-phase-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.emails-phase-chip {
  flex: 0 0 auto;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--ink-muted);
  cursor: pointer;
  white-space: nowrap;
}

.emails-phase-chip:hover {
  border-color: #c9b57d;
  color: var(--ink);
}

.emails-phase-chip.active {
  border-color: #c9b57d;
  background: color-mix(in srgb, var(--card-bg) 90%, #fff8e1 10%);
  color: var(--ink);
}

.emails-phase-chip span {
  font: 600 11px 'Inter', sans-serif;
}

.emails-phase-chip strong {
  color: var(--ink);
  font: 700 11px 'Inter', sans-serif;
}

.emails-surface-groups {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 12px;
}

.emails-surface-group {
  margin-bottom: 18px;
}

.emails-surface-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
}

.emails-surface-label span {
  letter-spacing: 0;
  color: var(--ink-light);
}

.emails-template-row {
  position: relative;
  width: 100%;
  min-height: 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.emails-template-row:hover,
.emails-template-row.active {
  border-color: #c9b57d;
  box-shadow: 0 10px 24px rgba(26, 23, 18, 0.05);
}

.emails-template-row strong,
.emails-template-row em {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emails-template-row strong {
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 650;
}

.emails-template-row em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-muted);
}

.emails-template-row i {
  color: var(--ink-light);
}

.emails-template-row b {
  position: absolute;
  top: 7px;
  right: 30px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a6d2f;
}

.emails-empty-list {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.5;
}

.emails-preview-pane {
  min-width: 0;
  padding: 22px;
  overflow: hidden;
}

.emails-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.emails-preview-head h2 {
  margin: 3px 0 4px;
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1;
  font-weight: 500;
  color: var(--ink);
}

.emails-preview-head p {
  margin: 0;
  max-width: 680px;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.45;
}

.emails-preview-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.emails-device-toggle {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.emails-device-toggle button,
.emails-save-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.emails-device-toggle button {
  padding: 0 10px;
  background: transparent;
  color: var(--ink-muted);
}

.emails-device-toggle button.active {
  background: var(--card-bg);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(26, 23, 18, 0.08);
}

.emails-save-btn {
  padding: 0 13px;
  background: #173f31;
  color: white;
}

.emails-save-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Floating save: the header Save scrolls out of reach on long editors, so a
   fixed pill follows the viewport and surfaces only when there are unsaved
   changes. */
.emails-save-fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 60;
  display: none;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: #173f31;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(26, 23, 18, 0.26);
}
.emails-save-fab.is-visible { display: inline-flex; }
.emails-save-fab:hover { opacity: 0.92; }
.emails-save-fab > i { font-size: 16px; }

.emails-meta-chips,
.emails-inbox-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.emails-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 600;
}

.emails-chip.is-editable {
  border-color: #c9b57d;
  background: color-mix(in srgb, var(--card-bg) 88%, #fff8e1 12%);
  color: #6f5c25;
}

.emails-chip.is-auto {
  border-color: #d9dee6;
  background: #f3f5f8;
  color: #586173;
}

.emails-inbox-strip {
  align-items: stretch;
  gap: 10px;
  margin-bottom: 12px;
}

.emails-inbox-strip div {
  flex: 1 1 260px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  background: var(--card-bg);
}

.emails-inbox-strip span,
.emails-inbox-strip strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emails-inbox-strip span {
  margin-bottom: 4px;
  color: var(--ink-light);
  font: 700 10px 'Inter', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.emails-inbox-strip strong {
  color: var(--ink);
  font: 600 12px 'Inter', sans-serif;
}

.emails-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 18px;
  height: calc(100vh - 250px);
  min-height: 560px;
}

.emails-rendered-preview {
  min-width: 0;
  display: flex;
  justify-content: center;
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--border);
  background:
    linear-gradient(90deg, rgba(26, 23, 18, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(26, 23, 18, 0.035) 1px, transparent 1px),
    #f5efe6;
  background-size: 24px 24px;
}

.emails-preview-frame-shell {
  width: min(100%, 760px);
  transition: width 0.18s ease;
}

.emails-rendered-preview.mobile .emails-preview-frame-shell {
  width: 390px;
  max-width: 100%;
}

.emails-preview-frame-shell iframe {
  display: block;
  width: 100%;
  min-height: 100%;
  height: calc(100vh - 314px);
  border: 1px solid #ded4c5;
  border-radius: 10px;
  background: white;
  box-shadow: 0 18px 42px rgba(26, 23, 18, 0.12);
}

.emails-inspector {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.emails-inspector-tabs {
  flex: 0 0 auto;
}

.emails-inspector-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.emails-editor-card,
.emails-tags-card,
.emails-context-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  padding: 16px;
}

.emails-readonly-friendly {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid #e6dfd2;
  border-radius: 8px;
  background: var(--bg);
  margin-bottom: 14px;
}

.emails-readonly-friendly i {
  font-size: 18px;
  color: #b49b55;
}

.emails-readonly-friendly strong {
  font-size: 13px;
  color: var(--ink);
}

.emails-readonly-friendly span {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-muted);
}

/* Structured blocks */
.emails-block > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.emails-block > span i {
  color: var(--ink-light);
}

.emails-block-button,
.emails-block-image {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.emails-img-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.emails-img-row img,
.emails-img-empty {
  width: 76px;
  height: 76px;
  flex: 0 0 auto;
  object-fit: cover;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.emails-img-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-light);
  font-size: 22px;
}

.emails-img-fields {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 7px;
}

.emails-img-replace {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-muted);
  font: 700 12px 'Inter', sans-serif;
  cursor: pointer;
}

.emails-block-button input,
.emails-block-image input {
  width: 100%;
  box-sizing: border-box;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: 400 13px 'Inter', sans-serif;
  outline: none;
}

.emails-context-grid {
  display: grid;
  gap: 10px;
}

.emails-context-grid div {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}

.emails-context-grid div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.emails-context-grid span {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-light);
  font: 700 10px 'Inter', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.emails-context-grid p {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
}

.emails-context-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid #dce8de;
  border-radius: 8px;
  background: #f1f8f2;
  color: #27523d;
  font-size: 11px;
  font-weight: 650;
}

.emails-editor-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.emails-editor-title em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-light);
}

.emails-field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.emails-field span {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
}

.emails-slot-edited {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 600;
  font-style: normal;
  color: #7C4E2D;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.emails-field input,
.emails-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: 400 13px/1.55 'Inter', sans-serif;
  outline: none;
}

.emails-field input {
  min-height: 40px;
  padding: 0 12px;
}

.emails-field textarea {
  min-height: 200px;
  padding: 12px;
  resize: vertical;
}

.emails-block textarea {
  min-height: 96px;
}

.emails-field input:focus,
.emails-field textarea:focus {
  border-color: #b49b55;
  box-shadow: 0 0 0 3px rgba(180, 155, 85, 0.14);
}

.emails-editor-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.emails-editor-actions button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink-muted);
  font: 700 12px 'Inter', sans-serif;
  cursor: pointer;
}

.emails-editor-actions button:disabled {
  opacity: 0.45;
  cursor: default;
}

.emails-readonly-copy strong {
  display: block;
  margin: 12px 0 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
}

.emails-readonly-copy p,
.emails-readonly-copy pre {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.55;
}

.emails-readonly-copy pre {
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: 'Inter', sans-serif;
  color: var(--ink-muted);
}

.emails-tag-group {
  padding: 12px 0;
  border-top: 1px solid var(--border-light);
}

.emails-tag-group:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.emails-tag-group p {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 0;
}

.emails-tag-group button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

.emails-tag-group button:disabled {
  opacity: 0.5;
  cursor: default;
}

.emails-tag-group code {
  font-size: 11px;
}

/* Slash-command tag picker */
.emails-slash-menu {
  position: fixed;
  z-index: 1000;
  max-height: 260px;
  overflow: auto;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  box-shadow: 0 16px 40px rgba(26, 23, 18, 0.16);
}

.emails-slash-menu button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.emails-slash-menu button.is-active,
.emails-slash-menu button:hover {
  background: var(--bg);
}

.emails-slash-menu code {
  font-size: 12px;
  color: var(--ink);
}

.emails-slash-menu span {
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-light);
}

@media (max-width: 1500px) {
  .emails-detail {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .emails-template-list {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .emails-surface-groups {
    flex: none;
    max-height: 360px;
  }

  .emails-workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .emails-preview-frame-shell iframe {
    height: 620px;
  }

  .emails-inspector {
    overflow: visible;
  }

  .emails-inspector-body {
    overflow: visible;
  }
}

@media (max-width: 1180px) {
  .emails-workspace {
    height: auto;
  }
}

@media (max-width: 820px) {
  .emails-detail {
    display: block;
    min-height: auto;
    border-inline: 0;
  }

  .emails-template-list {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 16px;
  }

  .emails-surface-groups {
    flex: none;
    max-height: 380px;
    padding-right: 0;
  }

  .emails-preview-pane {
    padding: 16px;
  }

  .emails-preview-head,
  .emails-preview-actions,
  .emails-workspace {
    display: grid;
    grid-template-columns: 1fr;
  }

  .emails-preview-actions {
    justify-items: stretch;
  }

  .emails-device-toggle,
  .emails-save-btn {
    width: 100%;
  }

  .emails-device-toggle button {
    flex: 1 1 0;
  }

  .emails-workspace {
    min-height: 0;
  }

  .emails-rendered-preview {
    padding: 14px;
  }

  .emails-preview-frame-shell iframe {
    height: 620px;
  }
}
