:root {
  --brand: #2e7d32;
  --text: #1d2939;
  --muted: #667085;
  --border: #d0d5dd;
  --bg: #f4f5f7;
  --error: #b42318;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
.muted { color: var(--muted); }
button { font: inherit; padding: 10px 20px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.link { border: 0; background: none; padding: 0; color: var(--brand); text-decoration: underline; }
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: 14px; }
input, textarea { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--border); }
.banner { margin: 12px 20px 0; padding: 10px 14px; background: #fffaeb; border: 1px solid #fedf89; border-radius: 6px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; padding: 20px; max-width: 1200px; margin: 0 auto; }
.editor, .fields { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 16px 20px; }
.fields { align-self: start; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; }
.fields summary { font-weight: 700; cursor: pointer; }
.fields h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 6px; }
.hint { font-size: 13px; }

.chip { display: flex; justify-content: space-between; gap: 8px; margin: 4px 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #f9fafb; color: var(--muted); user-select: none; }
.chip b { color: var(--text); font-weight: 600; white-space: nowrap; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover, .chip:focus-visible { border-color: var(--brand); }

.small { font-size: 13px; margin: 6px 0 0; }
.chip { cursor: grab; }
.chip-empty span { color: #b54708; }

/* The email, edited in place. Mirrors the frame in lib/doc.js renderEmail(). */
.canvas { margin-top: 16px; padding: 20px 12px; background: #eef0f3; border-radius: 8px; }
.email { max-width: 600px; margin: 0 auto; background: #fff; border-radius: 8px; }
.email-logo { text-align: center; padding: 32px 32px 24px; }
.email-logo img { max-width: 180px; max-height: 80px; }
.email-footer { padding: 20px 32px; border-top: 1px solid #e3e6ea; }
.blk { position: relative; margin: 0 20px 8px; padding: 26px 12px 12px; border: 1px dashed transparent; border-radius: 6px; }
.blk:hover, .blk:focus-within { border-color: var(--border); }
.blk.drop-before { box-shadow: 0 -3px 0 var(--brand); }
#blocks.drop-end { box-shadow: 0 3px 0 var(--brand); }
.blk-bar { position: absolute; top: 2px; left: 8px; right: 8px; display: flex; gap: 4px; align-items: center; opacity: 0; font-size: 12px; }
.blk:hover .blk-bar, .blk:focus-within .blk-bar { opacity: 1; }
.blk-bar .handle { cursor: grab; color: var(--muted); margin-right: auto; user-select: none; }
.blk-bar button, .blk-bar select { padding: 1px 8px; font-size: 12px; border-radius: 4px; }
[data-f] { outline: none; border-radius: 3px; cursor: text; }
[data-f]:hover { background: #f5faf5; }
[data-f]:focus { box-shadow: 0 0 0 2px #abefc6; background: #fff; }
[data-f]:empty::before { content: 'Type here…'; color: #98a2b3; }
.blk-table [data-f*=".rows."][data-f$=".0"]::first-line { font-weight: 700; color: var(--text); }
.ed-x { width: 28px; padding: 0 4px; vertical-align: middle; }
.ed-x button { padding: 0 6px; border: 0; background: none; color: var(--muted); font-size: 16px; }
.ed-x button:hover { color: var(--error); }
.col-x { float: right; display: flex; margin: -4px -6px 0 4px; opacity: 0; }
.blk-table td[align="right"] .col-x { float: left; margin: -4px 4px 0 -6px; }
.col-x button { padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 15px; line-height: 1; }
.col-x button:hover { color: var(--brand); }
.col-x button[data-act="delcol"]:hover { color: var(--error); }
.blk:hover .col-x, .blk:focus-within .col-x { opacity: 1; }
.ph { display: inline; padding: 1px 4px; border-radius: 4px; background: #ecfdf3; box-shadow: inset 0 0 0 1px #abefc6; cursor: default; }
.ph-empty { background: #fffaeb; box-shadow: inset 0 0 0 1px #fedf89; color: #b54708; }
.add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 32px 24px; }
.add button { padding: 4px 10px; font-size: 13px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.status { min-height: 1.4em; margin: 10px 0 0; }
.status.ok { color: var(--brand); font-weight: 600; }
.status.error { color: var(--error); }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 28px 24px; }
.login h1 { margin: 0 0 8px; font-size: 22px; }
.login button { width: 100%; margin-top: 20px; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
  .fields { position: static; max-height: none; }
  .top { padding: 10px 12px; }
  .banner { margin: 12px 12px 0; }
  .actions button { flex: 1; padding: 14px; }
  .blk { margin: 0 4px 8px; }
  .add { margin: 8px 16px 20px; }
  .email-logo, .email-footer { padding-left: 16px; padding-right: 16px; }
}
