/* Settings email library; the paper's inline styles also travel to email. */
.sx-wrap:has(.em-library) .sx-main { max-width: 1240px; }
.sx-wrap:has(.em-library) .sx-rail { min-width: 0; }
.em-library { display: grid; grid-template-columns: 248px minmax(0,1fr); gap: 24px; align-items: start; }
.em-library button:not(.btn) { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 6px 10px; color: var(--ink); font: inherit; font-size: 12.5px; cursor: pointer; transition: background .12s, border-color .12s; }
.em-library button:not(.btn):not(.on):hover:not(:disabled) { background: #f4f7fb; border-color: #d3dbe6; }
.em-library button:disabled { opacity: .45; cursor: default; }
.em-library button.on:not(.btn) { color: var(--blue); background: var(--blue-bg); border-color: var(--blue-line); }
.em-library .btn { font-size: 12.5px; padding: 7px 16px; }
.em-library .btn:disabled { opacity: .45; cursor: default; }
.em-flex { flex: 1; }
.em-sep { width: 1px; align-self: stretch; background: var(--line); margin: 2px 4px; }

/* ---- the list ---- */
.em-list { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: var(--shadow); }
.em-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 12px 10px 14px; border-bottom: 1px solid var(--line-soft); font-size: 12px; color: var(--muted); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.em-picker { display: none; }
.em-group-box { padding: 4px 8px 8px; }
.em-group-box + .em-group-box { border-top: 1px solid var(--line-soft); }
.em-group-top { display: flex; align-items: center; justify-content: space-between; margin: 10px 6px 6px; }
.em-group-top .em-group { margin: 0; }
.em-group { margin: 10px 6px 6px; font-size: 10.5px; letter-spacing: .6px; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.em-library button.em-template:not(.btn) { position: relative; display: block; text-align: left; width: 100%; padding: 8px 10px; margin: 1px 0; border-color: transparent; border-radius: 8px; }
.em-library button.em-template.on:not(.btn) { background: var(--blue-bg); border-color: var(--blue-line); }
.em-template b { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 12px; }
.em-template.on b { color: var(--blue); }
.em-template span { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.em-dot { display: none; position: absolute; top: 12px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.em-template.unsaved .em-dot { display: block; }
.em-tag { font-style: normal; font-size: 10px; font-weight: 600; color: var(--green); background: var(--green-bg); border-radius: 4px; padding: 1px 5px; margin-right: 6px; }
.em-auto { margin: 0 4px 6px; padding: 10px 10px 8px; border-radius: 8px; background: var(--grey-bg); }
.em-auto-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.em-auto p { margin: 6px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--muted); }
.em-auto p.em-warn { color: var(--amber); font-weight: 600; }
.em-library button.em-link:not(.btn) { border: 0; background: none; padding: 0; color: var(--blue); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; }
.em-library button.em-link:not(.btn):hover { background: none; text-decoration: underline; }
.em-library button.em-link.danger:not(.btn) { color: var(--red); }
.em-switch { position: relative; display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.em-switch input { position: absolute; left: 0; top: 50%; transform: translateY(-50%); margin: 0; width: 30px; height: 17px; opacity: 0; cursor: pointer; z-index: 1; }
.em-switch span { width: 30px; height: 17px; border-radius: 9px; background: #c3ccd8; position: relative; transition: background .15s; flex: none; }
.em-switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #0003; transition: left .15s; }
.em-switch input:checked + span { background: var(--green); }
.em-switch input:checked + span::after { left: 15px; }
.em-switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---- the editor ---- */
.em-workspace { min-width: 0; }
.em-head { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; gap: 16px; padding: 10px 0 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.em-head-l { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.em-title { width: 100%; min-width: 0; font: inherit; font-size: 18px; font-weight: 700; color: var(--ink); border: 1px solid transparent; background: transparent; border-radius: 7px; padding: 5px 8px; margin-left: -8px; }
.em-title:hover { border-color: var(--line); background: var(--surface); }
.em-title:focus { outline: none; border-color: var(--blue-line); background: var(--surface); box-shadow: 0 0 0 3px var(--blue-bg); }
.em-badge { font-size: 12px; color: var(--faint); padding: 0 0 0 1px; white-space: nowrap; }
.em-badge.auto { color: var(--green); font-weight: 600; }
.em-badge.auto.paused { color: var(--amber); }
.em-badge.auto::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.em-head-r { display: flex; align-items: center; gap: 8px; flex: none; }
.em-save-state { font-size: 12px; color: var(--faint); margin-right: 4px; white-space: nowrap; }
.em-head.dirty .em-save-state { color: var(--amber); font-weight: 600; }
.em-head.dirty .em-save-state::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); margin-right: 6px; vertical-align: 1px; }
.em-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 12px 0 0; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.em-note b { color: var(--ink); font-weight: 600; }
.em-system { display: block; }
.em-system span { display: block; font-size: 12px; color: var(--faint); margin-top: 2px; }
.em-welcome-for.on { border-color: var(--green-line); background: #f6fcf8; }
.em-library .em-welcome-for button { font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.em-library .em-welcome-for button.on { background: var(--green); border-color: var(--green); color: #fff; }
.em-welcome-for small { flex-basis: 100%; font-size: 12px; color: var(--faint); }
.em-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 14px 0 12px; }
.em-mode { display: inline-flex; padding: 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.em-library .em-mode button { border: 0; border-radius: 7px; padding: 5px 14px; font-weight: 600; color: var(--muted); }
.em-library .em-mode button.on { background: var(--ink); color: #fff; border: 0; }
.em-doc { border: 1px solid #dcd8d2; border-radius: 10px; background: var(--surface); box-shadow: 0 2px 10px #15283b08; }
.em-toolbar { position: sticky; top: 81px; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 7px 8px; background: #fafbfc; border-bottom: 1px solid var(--line); border-radius: 10px 10px 0 0; }
.em-toolbar select { padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font: inherit; font-size: 12.5px; color: var(--ink); min-width: 108px; }
.em-library .em-toolbar button { border-color: transparent; background: transparent; padding: 5px 9px; }
.em-library .em-toolbar button:hover { border-color: var(--line); background: var(--surface); }
.em-line-above { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); padding: 0 6px; }
.em-line-above[hidden] { display: none; }
.em-menu { position: relative; }
.em-menu summary { list-style: none; cursor: pointer; font-size: 12.5px; padding: 5px 9px; border-radius: 7px; border: 1px solid transparent; user-select: none; color: var(--ink); }
.em-menu summary:hover, .em-menu[open] summary { border-color: var(--line); background: var(--surface); }
.em-menu summary::-webkit-details-marker { display: none; }
.em-insert summary { list-style: none; cursor: pointer; font-size: 12.5px; padding: 5px 10px; border-radius: 7px; border: 1px solid #ecdcb8; background: #fbf6ec; color: #6b4e1f; user-select: none; }
.em-menu summary::after { content: " ▾"; font-size: 10px; }
.em-add .em-menu-list { left: 0; right: auto; }
.em-menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; min-width: 170px; padding: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; box-shadow: 0 10px 28px #14283a24; }
.em-library .em-menu-list button { display: block; width: 100%; text-align: left; border-color: transparent; padding: 7px 10px; }
.em-library .em-insert .em-menu-list button { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.em-paper { padding: 32px 38px 40px; background: var(--surface); overflow-wrap: anywhere; }
.em-preview { border: 1px solid #dcd8d2; border-radius: 10px; box-shadow: 0 2px 10px #15283b08; }
.em-subj { display: flex; align-items: center; gap: 12px; padding: 0 0 12px; margin: 0 0 20px; border-bottom: 1px solid var(--line-soft); font: 13px Arial, sans-serif; }
.em-subj + .em-subj { margin-top: -14px; }
.em-subj span { flex: 0 0 64px; color: var(--faint); font-size: 12px; }
.em-subj input { flex: 1; min-width: 0; border: 0; padding: 4px 0; font: 600 14px Arial, sans-serif; color: var(--ink); background: transparent; }
.em-subj input:focus { outline: none; }
.em-subj:focus-within { border-bottom-color: var(--blue-line); }
.em-block { position: relative; border-radius: 3px; }
.em-edit { outline: none; min-height: 16px; }
.em-edit:empty::before { content: 'Write here…'; color: #a0a0a0; font-weight: normal; text-decoration: none; }
.em-block.selected::before { content: ""; position: absolute; left: -20px; top: 1px; bottom: 1px; width: 3px; border-radius: 2px; background: var(--blue); opacity: .55; }
.em-library .em-guide { color: var(--muted); font-size: 12px; line-height: 1.6; margin: 10px 2px; }
.em-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 2px 4px; font-size: 12px; color: var(--faint); }
.em-personalise { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; color: var(--muted); font-size: 12px; }
.em-personalise label { display: flex; align-items: center; gap: 8px; }
.em-personalise input { width: 130px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.em-subject { font: 600 13px Arial,sans-serif; border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 22px; }
.em-empty { text-align: center; padding: 50px 20px; border: 1px dashed var(--line); border-radius: 12px; }
.em-empty p { color: var(--muted); }

/* ---- welcome email history ---- */
.em-modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; background: #0f172a66; }
.em-dialog { width: min(640px, 100%); max-height: min(720px, calc(100vh - 48px)); display: flex; flex-direction: column; background: var(--surface); border-radius: 14px; box-shadow: 0 24px 60px #0f172a40; }
.em-dialog-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.em-dialog-head h3 { flex: 1; margin: 0; font-size: 15px; }
.em-dialog-head button { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 5px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.em-dialog-head .em-x { border: 0; font-size: 20px; line-height: 1; padding: 2px 6px; color: var(--muted); }
.em-dialog-body { overflow: auto; padding: 4px 18px; }
.em-hrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.em-hrow b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.em-hrow small { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.em-hrow .em-herr { color: var(--amber); }
.em-pill { flex: none; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 3px 9px; }
.em-pill.green { color: var(--green); background: var(--green-bg); } .em-pill.amber { color: var(--amber); background: var(--amber-bg); }
.em-pill.blue { color: var(--blue); background: var(--blue-bg); } .em-pill.grey { color: var(--muted); background: var(--grey-bg); }
.em-empty-note { color: var(--muted); font-size: 13px; padding: 22px 0; text-align: center; margin: 0; }
.em-dialog-foot { margin: 0; padding: 12px 18px 16px; border-top: 1px solid var(--line); font-size: 11.5px; line-height: 1.6; color: var(--muted); }

.em-card { font-family: Georgia, "Times New Roman", serif; color: #2e2620; }
.em-reorder-bar > span { font-size: 12px; color: var(--muted); margin: 0 8px 0 4px; min-width: 96px; }
.em-library .em-reorder-bar button:disabled { opacity: .45; cursor: default; }
.em-outline { padding: 8px; user-select: none; }
.em-row { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 6px; border: 1px solid transparent; cursor: grab; font-size: 12.5px; line-height: 1.35; position: relative; }
.em-row:hover { background: #f5f8fc; }
.em-row.on { background: #edf4ff; border-color: #c4d7f5; }
.em-row.drop-before::before, .em-row.drop-after::after { content: ""; position: absolute; left: 6px; right: 6px; height: 2px; background: var(--blue, #2f6fde); border-radius: 2px; }
.em-row.drop-before::before { top: -2px; } .em-row.drop-after::after { bottom: -2px; }
.em-grip { color: #a9b3c0; font-size: 12px; }
.em-row-role { flex: 0 0 76px; font-size: 10px; letter-spacing: .3px; text-transform: uppercase; color: var(--muted); }
.em-row-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #55606d; }
.em-row-section { margin-top: 8px; } .em-row-section .em-row-text { font-weight: 700; color: #4d382b; font-size: 13.5px; }
.em-row-subheading .em-row-text { font-weight: 700; color: var(--ink); padding-left: 10px; }
.em-row-label .em-row-text { font-weight: 600; color: var(--ink); padding-left: 20px; }
.em-row-body .em-row-text { padding-left: 20px; }
.em-row-divider .em-row-text { border-top: 1px solid #d7cec5; height: 0; margin: 0 20px; }
.em-testbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -4px 0 16px; padding: 10px 12px; border: 1px solid #c4d7f5; background: #f5f9ff; border-radius: 10px; font-size: 12px; }
.em-testbar label { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.em-testbar input { width: 260px; max-width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font: inherit; }
.em-testbar .btn { font-size: 12px; padding: 7px 14px; }
.em-testbar > span { color: var(--muted); flex-basis: 100%; }
/* automatic emails: edited and previewed in the card they are sent in */
.em-card .em-edit { font-family: Georgia, "Times New Roman", serif; color: #2e2620; }
.em-c-body { font-size: 16px; line-height: 1.6; margin: 0 0 14px; }
.em-c-section { font-size: 26px; line-height: 1.25; margin: 0 0 18px; }
.em-c-subheading { font-size: 18px; line-height: 1.4; font-weight: bold; margin: 0 0 10px; }
.em-c-label { font: 11px Helvetica, Arial, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: #8a7c6e; margin: 0 0 6px; }
.em-framed { background: #f4eee7; padding: 22px; }
.em-framed .em-subject { font-family: Arial, sans-serif; }
.em-frame { max-width: 560px; margin: 0 auto; }
.em-frame-card { background: #fff; border-radius: 14px; padding: 36px 32px; border: 1px solid #ece3d9; }
.em-frame-logo { display: block; width: 150px; height: auto; margin: 0 0 14px; }
.em-frame-eyebrow { margin: 0 0 6px; font: 11px Helvetica, Arial, sans-serif; letter-spacing: 2px; text-transform: uppercase; color: #d8a85f; }
.em-frame-cta { margin: 12px 0 8px; } .em-frame-cta span { display: inline-block; background: #2e2620; color: #f4eee7; padding: 14px 28px; border-radius: 999px; font: 15px Helvetica, Arial, sans-serif; }
.em-frame-next { margin: 18px 0 0; font: 13px/1.6 Helvetica, Arial, sans-serif; color: #8a7c6e; }
.em-frame-foot { margin: 18px 8px 0; font: 12px/1.6 Helvetica, Arial, sans-serif; color: #8a7c6e; }
.em-frame-details { width: 100%; margin: 0 0 24px; border-top: 1px solid #ece3d9; border-collapse: collapse; }
.em-frame-details td { padding: 10px 14px 0 0; vertical-align: top; font-size: 15px; line-height: 1.55; }
.em-frame-details td:first-child { width: 104px; font: 11px/1.7 Helvetica, Arial, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: #8a7c6e; }

@media (max-width: 1100px) {
  .em-library { grid-template-columns: minmax(0,1fr); gap: 14px; }
  .em-list { position: static; max-height: none; overflow: visible; }
  .em-picker { display: block; width: calc(100% - 24px); margin: 10px 12px 12px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font: inherit; font-size: 14px; color: var(--ink); }
  .em-rows, .em-group-box:not(:first-of-type), .em-group-box .em-group { display: none; }
  .em-group-box { padding: 0 8px 8px; border: 0; }
  .em-head { flex-wrap: wrap; }
}
@media (max-width: 600px) {
  .em-paper { padding: 22px 16px 22px 22px; }
  .em-block.selected::before { left: -12px; }
  .em-head-l { flex-basis: 100%; flex-wrap: wrap; }
  .em-head-r { flex-basis: 100%; }
  .em-save-state { margin-right: auto; }
  .em-toolbar { top: 0; position: static; }
    .em-framed { padding: 10px; } .em-frame-card { padding: 24px 18px; }
  .em-foot { flex-direction: column; align-items: flex-start; }
}
