:root {
  --ink: #0e0e0e;
  --ink-2: #4a4a4a;
  --ink-3: #8a8a8a;
  --line: #e6e6e6;
  --line-2: #d4d4d4;
  --bg: #fafafa;
  --card: #ffffff;
  --accent: #0e0e0e;
  --ok: #1d7a46;
  --ok-bg: #eaf6ef;
  --err: #b42318;
  --err-bg: #fdeeed;
  --warn-bg: #fff6e0;
  --radius: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; background: var(--ink); color: #fff; }
.top-in { max-width: 1200px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 28px; }
.brand { font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; font-size: 13px; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; display: inline-block; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { color: #bdbdbd; text-decoration: none; padding: 6px 12px; border-radius: 6px; font-size: 14px; }
.nav a:hover, .nav a.on { color: #fff; background: #262626; }
.top form { margin: 0; }
.top .who { font-size: 13px; color: #bdbdbd; display: flex; align-items: center; gap: 12px; }
.linkbtn { background: none; border: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
.testbar { background: #ffe8a3; color: #3d2f00; text-align: center; font-size: 13px; padding: 6px 12px; }

/* layout */
.page { max-width: 1200px; margin: 0 auto; padding: 32px 24px 80px; }
.page.narrow { max-width: 720px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g2 { grid-template-columns: 1fr; } }
.section { margin-top: 36px; }
.section > .row:first-child { justify-content: space-between; margin-bottom: 12px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.pad0 { padding: 0; overflow: hidden; }
a.card { text-decoration: none; display: block; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--ink); }
.client-card .swatch { width: 36px; height: 36px; border-radius: 8px; margin-bottom: 14px; border: 1px solid rgba(0,0,0,.08); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; }
.client-card .stats { display: flex; gap: 18px; margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.client-card .stats b { color: var(--ink); font-size: 15px; display: block; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.stat .v { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin-top: 4px; }
.stat .s { font-size: 13px; color: var(--ink-2); }
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--card); }
.empty h3 { margin-bottom: 6px; color: var(--ink); }

/* tables */
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fcfcfc; }
.t td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t td.num, .t th.num { text-align: right; font-variant-numeric: tabular-nums; }
.t a { text-decoration: none; font-weight: 550; }
.t a:hover { text-decoration: underline; }
.t .actions { text-align: right; white-space: nowrap; }
.t .actions form { display: inline; }

/* pills */
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #efefef; color: var(--ink-2); text-transform: capitalize; }
.pill.sent, .pill.subscribed { background: var(--ok-bg); color: var(--ok); }
.pill.sending, .pill.scheduled { background: #e8efff; color: #2346a8; }
.pill.unsubscribed { background: #f2f2f2; color: var(--ink-3); }
.pill.bounced, .pill.complained, .pill.failed { background: var(--err-bg); color: var(--err); }

/* forms */
label { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 8px; padding: 9px 12px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(0,0,0,.07); }
input[type=color] { width: 48px; height: 40px; padding: 2px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; cursor: pointer; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 14px; }
.check input { margin-top: 3px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 600; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; transition: opacity .15s, background .15s; }
.btn:hover { opacity: .88; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-2); }
.btn.ghost:hover { border-color: var(--ink); opacity: 1; }
.btn.danger { background: #fff; color: var(--err); border-color: #f1c2bd; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
form.inline { display: inline; margin: 0; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 14px; font-weight: 500; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.note { background: var(--warn-bg); border-radius: 8px; padding: 12px 16px; font-size: 13.5px; }

/* auth pages */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.auth .card { width: 100%; max-width: 400px; padding: 32px; }
.auth h1 { font-size: 24px; margin: 18px 0 6px; }
.auth .brand { color: var(--ink); }
.auth .brand-dot { background: var(--ink); }

/* progress */
.bar { height: 8px; background: #eee; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ink); border-radius: 99px; transition: width .4s; }

/* ---------------- editor ---------------- */
body.editor-page { background: #f1f1f1; }
.ed-top { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 15; }
.ed-top-in { padding: 10px 20px; display: flex; gap: 12px; align-items: center; }
.ed-top input.name { border: 0; font-size: 17px; font-weight: 650; padding: 6px 8px; max-width: 360px; background: transparent; }
.ed-top input.name:hover { background: #f5f5f5; }
.ed-top .save-state { font-size: 13px; color: var(--ink-3); flex: 1; }
.ed { display: grid; grid-template-columns: 240px minmax(0, 1fr) 340px; height: calc(100vh - 56px - 61px); }
.ed.testmode { height: calc(100vh - 56px - 61px - 32px); }
.ed-col { overflow-y: auto; }
.palette { background: #fff; border-right: 1px solid var(--line); padding: 18px 16px; }
.palette h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 10px; }
.palette-items { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pal { border: 1px solid var(--line-2); border-radius: 8px; padding: 12px 6px 10px; text-align: center; font-size: 12.5px; font-weight: 600; cursor: grab; user-select: none; background: #fff; transition: border-color .12s, box-shadow .12s; }
.pal:hover { border-color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.pal svg { display: block; margin: 0 auto 6px; width: 22px; height: 22px; }
.palette .tip { font-size: 12.5px; color: var(--ink-3); margin-top: 16px; line-height: 1.5; }

.canvas-wrap { padding: 28px 24px 120px; }
.mail { max-width: 600px; margin: 0 auto; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.05); overflow: hidden; }
.mail-head { padding: 26px 32px; text-align: center; font-weight: 700; font-size: 20px; }
.mail-head img { max-height: 48px; max-width: 70%; display: inline-block; vertical-align: middle; }
.canvas { min-height: 220px; padding: 16px 0 20px; }
.canvas.empty-canvas::after { content: "Drag blocks here from the left"; display: block; margin: 20px 32px; padding: 50px 20px; border: 2px dashed var(--line-2); border-radius: 8px; text-align: center; color: var(--ink-3); font-size: 14px; }
.mail-foot { text-align: center; font-size: 12px; color: #888; padding: 18px 32px 28px; border-top: 1px solid #f0f0f0; line-height: 1.6; }

.blk { position: relative; padding: 8px 32px; border: 2px solid transparent; cursor: pointer; }
.blk:hover { border-color: #cfd8ff; }
.blk.sel { border-color: #3557d4; background: rgba(53,87,212,.03); }
.blk .tools { position: absolute; right: 6px; top: -14px; display: none; gap: 4px; z-index: 3; }
.blk:hover .tools, .blk.sel .tools { display: flex; }
.blk .tools button, .blk .tools span { width: 28px; height: 26px; border-radius: 6px; border: 1px solid var(--line-2); background: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; color: var(--ink-2); }
.blk .tools .handle { cursor: grab; }
.blk .tools button:hover { color: var(--ink); border-color: var(--ink); }
.blk .tools svg { width: 14px; height: 14px; }
.blk-ghost { opacity: .35; background: #eef2ff; }
.canvas .pal { margin: 6px 32px; height: 56px; display: grid; place-items: center; background: #eef2ff; border: 2px dashed #3557d4; color: #3557d4; }
.canvas .pal svg { display: none; }

/* block previews inside canvas */
.b-heading { font-weight: 700; line-height: 1.25; color: #111; }
.b-text { color: #333; font-size: 16px; line-height: 1.6; }
.b-text p { margin: 0 0 16px; }
.b-text p:last-child { margin-bottom: 4px; }
.b-img img { width: 100%; display: block; border-radius: 6px; }
.b-img .ph, .b-col .ph { background: #f1f1f1; color: #999; display: grid; place-items: center; border-radius: 6px; font-size: 13px; }
.b-img .ph { height: 180px; }
.b-btn a { display: inline-block; padding: 13px 26px; border-radius: 6px; font-weight: 600; text-decoration: none; font-size: 15px; }
.b-div { border-top: 1px solid #e5e5e5; margin: 10px 0; }
.b-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.b-col img { width: 100%; display: block; border-radius: 6px; margin-bottom: 10px; }
.b-col .ph { height: 120px; margin-bottom: 10px; }
.b-col .ct { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.b-col .cx { font-size: 14px; color: #444; line-height: 1.5; white-space: pre-line; }
.b-spacer { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 6px, #f2f2f2 6px, #f2f2f2 12px); border-radius: 4px; }

.inspector { background: #fff; border-left: 1px solid var(--line); padding: 20px; }
.inspector h3 { margin-bottom: 14px; }
.insp-empty { color: var(--ink-3); font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; padding: 7px 12px; border: 0; background: #fff; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line-2); }
.seg button.on { background: var(--ink); color: #fff; }
.img-field { display: flex; gap: 8px; }
.img-field input { flex: 1; }
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -4px 0 16px; }
.subtabs button { font: inherit; font-size: 13px; font-weight: 600; background: none; border: 0; padding: 8px 10px; cursor: pointer; color: var(--ink-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subtabs button.on { color: var(--ink); border-color: var(--ink); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal.open { display: flex; }
.modal .card { width: 100%; max-width: 480px; padding: 26px; }
.modal.wide .card { max-width: 760px; }
.modal h2 { margin-bottom: 8px; }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #f4f4f4; }
.devices { display: flex; gap: 8px; margin-bottom: 12px; }

@media (max-width: 1100px) { .ed { grid-template-columns: 200px minmax(0, 1fr) 300px; } }

/* public pages */
.public { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #f4f4f4; }
.public .card { max-width: 440px; width: 100%; text-align: center; padding: 36px 30px; }
.public h1 { font-size: 22px; margin-bottom: 10px; }
.public .logo { max-height: 44px; margin: 0 auto 18px; display: block; }
.editor-page > .flash { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; box-shadow: 0 6px 24px rgba(0,0,0,.15); margin: 0; }
