/* emailbuilder.co.uk — "post room" identity: ivory paper, ink navy, postbox red, airmail blue */

:root {
    --paper: #f5f1ea;
    --paper-2: #ece6db;
    --paper-3: #e4dccd;
    --card: #fffdf9;
    --ink: #1c2533;
    --ink-2: #4a5464;
    --ink-3: #8a8f98;
    --line: #e2dbcf;
    --line-2: #d3cbbd;

    --post: #d9472b;
    --post-deep: #b8381f;
    --post-soft: rgba(217, 71, 43, .1);
    --post-softer: rgba(217, 71, 43, .05);
    --air: #2a4d8f;
    --air-soft: rgba(42, 77, 143, .1);
    --sage: #4f7a5e;
    --sage-soft: rgba(79, 122, 94, .12);
    --ink-soft: rgba(28, 37, 51, .06);
    --ink-softer: rgba(28, 37, 51, .035);

    --font-ui: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Fraunces', Georgia, serif;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(28, 37, 51, .05), 0 10px 30px -14px rgba(28, 37, 51, .22);
    --shadow-lift: 0 2px 4px rgba(28, 37, 51, .06), 0 18px 40px -16px rgba(28, 37, 51, .3);
    --header-h: 64px;
    --stripe-h: 6px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

button, input, select, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

/* ---------- Masthead ---------- */

.masthead {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--ink);
    color: var(--paper);
}

.masthead-inner {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}

/* Postage stamp: dotted border in the header colour punches "perforations" into the paper */
.brand-stamp {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    background: var(--paper);
    color: var(--post);
    border: 4px dotted var(--ink);
    outline: 2px solid var(--paper);
    outline-offset: -6px;
    transform: rotate(-6deg);
    font-size: 15px;
    transition: transform .25s ease;
}

.brand:hover .brand-stamp { transform: rotate(3deg) scale(1.05); }

.brand-word {
    font-family: var(--font-ui);
    font-weight: 800;
    font-size: 20px;
    letter-spacing: -.02em;
}

.brand-word em {
    font-family: var(--font-display);
    font-weight: 500;
    font-style: italic;
    color: #f0b9a8;
    margin-right: 1px;
}

.masthead-nav { display: flex; align-items: center; gap: 10px; }

.masthead-nav a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    color: rgba(245, 241, 234, .8);
    background: rgba(245, 241, 234, .07);
    border: 1px solid rgba(245, 241, 234, .1);
    transition: background .2s, color .2s;
}

.masthead-nav a:hover { background: rgba(245, 241, 234, .14); color: var(--paper); }

.masthead-nav a.nav-icon { width: 36px; height: 36px; padding: 0; justify-content: center; }
.masthead-nav a.nav-icon:hover { background: rgba(217, 71, 43, .35); border-color: rgba(217, 71, 43, .5); }

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 4px 14px 4px 4px;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 600;
    color: rgba(245, 241, 234, .85);
}

.user-initial {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--post);
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14px;
}

.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Airmail envelope edge */
.airmail {
    height: var(--stripe-h);
    background: repeating-linear-gradient(-45deg,
        var(--post) 0 12px, var(--paper) 12px 18px,
        var(--air) 18px 30px, var(--paper) 30px 36px);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background .18s, border-color .18s, color .18s, transform .18s, box-shadow .18s;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--post);
    color: #fff;
    box-shadow: 0 6px 16px -8px rgba(217, 71, 43, .7);
}

.btn-primary:hover { background: var(--post-deep); }

.btn-soft {
    background: var(--ink-soft);
    border-color: rgba(28, 37, 51, .08);
    color: var(--ink);
}

.btn-soft:hover { background: rgba(28, 37, 51, .1); }

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--ink-softer);
    border-color: rgba(28, 37, 51, .07);
    color: var(--ink-2);
}

.btn-icon:hover { background: var(--ink-soft); color: var(--ink); }

.btn-danger:hover { background: var(--post-soft); color: var(--post); border-color: rgba(217, 71, 43, .2); }

.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ---------- Template library ---------- */

.library {
    max-width: 1240px;
    margin: 0 auto;
    padding: 48px 28px 72px;
}

.library-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 36px;
    padding-bottom: 28px;
    border-bottom: 1px dashed var(--line-2);
}

.kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--post);
}

.library-head h1 {
    margin: 6px 0 4px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(34px, 5vw, 52px);
    line-height: 1.05;
    letter-spacing: -.02em;
}

.lede { margin: 0; color: var(--ink-2); }

.tpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 26px;
}

.tpl-card {
    --thumb-scale: .38;
    display: flex;
    flex-direction: column;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform .25s ease, box-shadow .25s ease;
}

.tpl-card:hover { transform: translateY(-3px) rotate(-.3deg); box-shadow: var(--shadow-lift); }

.tpl-thumb {
    position: relative;
    display: block;
    height: 230px;
    overflow: hidden;
    background: var(--paper-2);
    border-bottom: 1px solid var(--line);
}

.tpl-thumb iframe {
    width: 680px;
    height: 620px;
    border: 0;
    transform: scale(var(--thumb-scale));
    transform-origin: top left;
    pointer-events: none;
}

.tpl-thumb::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 48px;
    background: linear-gradient(transparent, rgba(236, 230, 219, .9));
}

.tpl-body { padding: 16px 18px 6px; flex: 1; }

.tpl-name {
    display: block;
    font-weight: 700;
    font-size: 16px;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tpl-name:hover { color: var(--post); }

.tpl-meta {
    display: flex;
    gap: 14px;
    margin-top: 6px;
    font-size: 12.5px;
    color: var(--ink-3);
}

.tpl-meta i { margin-right: 3px; }

.tpl-actions {
    display: flex;
    gap: 6px;
    padding: 12px 18px 16px;
}

.tpl-actions .btn-soft { flex: 1; }

.empty {
    text-align: center;
    padding: 64px 24px;
    border: 2px dashed var(--line-2);
    border-radius: var(--radius);
    background: var(--card);
    margin-bottom: 26px;
}

.empty h2 { font-family: var(--font-display); font-size: 28px; margin: 22px 0 6px; }
.empty p { color: var(--ink-2); margin: 0 auto; max-width: 420px; }

.brand-stamp-lg {
    width: 76px;
    height: 76px;
    font-size: 28px;
    border-width: 6px;
    border-color: var(--card);
    outline-offset: -10px;
    outline-color: var(--paper);
    box-shadow: 0 8px 20px -10px rgba(28, 37, 51, .4);
}

/* ---------- Merge tags ---------- */

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

.tag-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.tag-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tag-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-3);
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.tag-table td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tag-table tr:last-child td { border-bottom: 0; }
.tag-table tr.is-builtin td { color: var(--ink-2); }

.tag-token {
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--post-softer);
    border: 1px solid rgba(217, 71, 43, .18);
    color: var(--post-deep);
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12.5px;
    white-space: nowrap;
}

.tag-sample { color: var(--ink-3); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-actions { width: 1%; white-space: nowrap; text-align: right; }
.tag-actions .btn-icon { width: 32px; height: 32px; }

.tag-builtin {
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--air-soft);
    color: var(--air);
    font-size: 11.5px;
    font-weight: 700;
    cursor: help;
}

.tag-form {
    position: sticky;
    top: calc(var(--header-h) + var(--stripe-h) + 20px);
    padding: 24px 22px;
    background: var(--card);
    border: 1px solid var(--line);
    border-top: 4px solid var(--post);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tag-form h2 { margin: 0; font-family: var(--font-display); font-size: 24px; }
.tag-form .envelope-sub { margin-bottom: 18px; }

.token-input { display: flex; align-items: center; gap: 6px; }
.token-input > span { font-family: ui-monospace, Consolas, monospace; font-weight: 700; color: var(--post); }
.token-input .input { font-family: ui-monospace, Consolas, monospace; }

.tag-form-actions { display: flex; gap: 8px; margin-top: 6px; }

.lede code { padding: 1px 6px; border-radius: 5px; background: var(--post-soft); color: var(--post-deep); font-size: .9em; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 900px) {
    .tags-layout { grid-template-columns: 1fr; }
    .tag-form { position: static; }
}

/* ---------- Sign in / register ---------- */

.auth {
    max-width: 1120px;
    min-height: calc(100vh - var(--header-h) - var(--stripe-h) - 120px);
    margin: 0 auto;
    padding: 56px 28px 72px;
    display: grid;
    grid-template-columns: 1fr minmax(0, 440px);
    align-items: center;
    gap: 64px;
}

.auth-intro h1 {
    margin: 14px 0 18px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(38px, 5.4vw, 64px);
    line-height: 1.02;
    letter-spacing: -.025em;
}

.auth-intro h1 em { font-weight: 500; color: var(--post); }
.auth-intro .lede { max-width: 440px; font-size: 16.5px; }

/* Airmail envelope: striped border, stamp in the corner */
.envelope {
    position: relative;
    padding: 38px 34px 30px;
    background: var(--card);
    border: 9px solid transparent;
    border-radius: 6px;
    border-image: repeating-linear-gradient(-45deg,
        var(--post) 0 12px, var(--card) 12px 18px,
        var(--air) 18px 30px, var(--card) 30px 36px) 9;
    box-shadow: var(--shadow-lift);
}

.envelope h2 { margin: 0; font-family: var(--font-display); font-size: 30px; font-weight: 700; letter-spacing: -.01em; }
.envelope-sub { margin: 4px 0 24px; color: var(--ink-3); font-size: 14px; }

.envelope-stamp {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 54px;
    height: 54px;
    font-size: 20px;
    border-width: 5px;
    border-color: var(--card);
    outline-color: var(--paper-2);
    outline-offset: -9px;
    transform: rotate(8deg);
    box-shadow: 0 4px 10px -4px rgba(28, 37, 51, .35);
}

.envelope .field-check { margin: 4px 0 22px; }
.envelope .input { padding: 11px 13px; font-size: 15px; }

.envelope-foot {
    margin: 20px 0 0;
    padding-top: 16px;
    border-top: 1px dashed var(--line-2);
    text-align: center;
    font-size: 14px;
    color: var(--ink-2);
}

.envelope-foot a { color: var(--post); font-weight: 700; text-decoration: none; }
.envelope-foot a:hover { text-decoration: underline; }

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    background: var(--post-soft);
    border: 1px solid rgba(217, 71, 43, .2);
    color: var(--post-deep);
    font-size: 13.5px;
    font-weight: 600;
}

.alert i { margin-top: 2px; }

.alert-ok { background: var(--sage-soft); border-color: rgba(79, 122, 94, .25); color: var(--sage); }

.field-label-split { display: flex; justify-content: space-between; align-items: baseline; }
.field-label-split a { font-weight: 600; font-size: 12.5px; color: var(--post); text-decoration: none; }
.field-label-split a:hover { text-decoration: underline; }

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 120;
    transform: translateX(-50%);
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 11px 18px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 14px 30px -12px rgba(28, 37, 51, .6);
}

.toast i { color: #8fc4a0; }
.toast.is-error i { color: #f0a08e; }

/* ---------- Footer ---------- */

.sitefoot { border-top: 1px dashed var(--line-2); }

.sitefoot-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 26px 28px 36px;
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--ink-3);
    font-size: 13px;
}

.sitefoot p { margin: 0; }

.postmark {
    width: 62px;
    height: 62px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 2px solid rgba(42, 77, 143, .45);
    box-shadow: inset 0 0 0 4px var(--paper), inset 0 0 0 5px rgba(42, 77, 143, .35);
    color: rgba(42, 77, 143, .7);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 11px;
    line-height: 1.1;
    text-align: center;
    transform: rotate(-12deg);
}

/* ---------- Editor shell ---------- */

.ed {
    height: calc(100vh - var(--header-h) - var(--stripe-h));
    display: flex;
    flex-direction: column;
}

.ed-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.ed-name {
    min-width: 0;
    flex: 0 1 340px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    font-family: var(--font-display);
    font-size: 19px;
    font-weight: 500;
}

.ed-name:hover { background: var(--ink-softer); }
.ed-name:focus { outline: none; background: var(--card); border-color: var(--line-2); box-shadow: 0 0 0 3px var(--air-soft); }

.ed-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-3);
    white-space: nowrap;
}

.ed-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.ed-status[data-kind="ok"] { color: var(--sage); }
.ed-status[data-kind="dirty"] { color: #b7791f; }
.ed-status[data-kind="busy"] { color: var(--air); }
.ed-status[data-kind="error"] { color: var(--post); }

.ed-bar-actions { margin-left: auto; display: flex; gap: 8px; }

.ed-history { display: flex; gap: 4px; padding-left: 12px; border-left: 1px solid var(--line); }
.btn:disabled { opacity: .4; cursor: default; pointer-events: none; }

.ed-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr) 320px;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.panel-title i { color: var(--post); }

.panel-hint { margin: 6px 0 16px; font-size: 13px; color: var(--ink-3); }
.panel-hint i { margin-right: 4px; }

/* Palette */

.ed-palette {
    padding: 22px 16px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--paper-2);
    border-right: 1px solid var(--line);
}

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

.palette-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: grab;
    user-select: none;
    transition: border-color .18s, box-shadow .18s, transform .18s;
}

.palette-item:hover {
    border-color: rgba(217, 71, 43, .35);
    box-shadow: 0 6px 16px -10px rgba(28, 37, 51, .35);
    transform: translateX(2px);
}

.palette-icon {
    width: 34px;
    height: 34px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--post-soft);
    color: var(--post);
}

.palette-item:nth-child(even) .palette-icon { background: var(--air-soft); color: var(--air); }

.palette-text { display: flex; flex-direction: column; min-width: 0; }
.palette-text strong { font-size: 14px; }
.palette-text small { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-grip { margin-left: auto; color: var(--line-2); }

.panel-title-sub { margin-top: 26px; padding-top: 18px; border-top: 1px dashed var(--line-2); }

.preset-item .palette-icon { background: var(--sage-soft); color: var(--sage); }
.preset-item .palette-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.preset-del {
    margin-left: auto;
    width: 26px;
    height: 26px;
    flex: none;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s, background .15s, color .15s;
}

.preset-item:hover .preset-del, .preset-del:focus { opacity: 1; }
.preset-del:hover { background: var(--post-soft); color: var(--post); }

.props-head-actions { display: flex; gap: 6px; }

/* Desk & sheet */

.ed-desk {
    --eu-body-bg: #f2efe9;
    overflow-y: auto;
    padding: 44px 32px 120px;
    background-color: var(--eu-body-bg);
    background-image: radial-gradient(rgba(28, 37, 51, .09) 1px, transparent 1px);
    background-size: 18px 18px;
}

.ed-sheet {
    --eu-link: #d9472b;
    position: relative;
    margin: 0 auto;
    box-shadow: 0 1px 3px rgba(28, 37, 51, .08), 0 24px 50px -24px rgba(28, 37, 51, .35);
}

.ed-sheet a { color: var(--eu-link); }

.ed-canvas { min-height: 40px; }
.ed-canvas.is-empty { min-height: 220px; }

.ed-empty {
    position: absolute;
    inset: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 2px dashed var(--line-2);
    border-radius: var(--radius-sm);
    color: var(--ink-3);
    font-weight: 600;
    pointer-events: none;
}

.ed-empty i { font-size: 22px; color: var(--post); }

/* Blocks on the canvas */

.blk { position: relative; outline: 1px dashed transparent; transition: outline-color .15s; }
.blk:hover { outline-color: rgba(42, 77, 143, .45); }
.blk.is-selected { outline: 2px solid var(--post); outline-offset: -1px; z-index: 2; }
.blk-ghost { opacity: .35; }

.blk-tools {
    position: absolute;
    top: -15px;
    left: 8px;
    right: 8px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    z-index: 3;
}

.blk:hover .blk-tools, .blk.is-selected .blk-tools { opacity: 1; }

.blk-tag, .blk-actions {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    height: 26px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--paper);
    font-family: var(--font-ui);
    font-size: 11.5px;
    font-weight: 700;
    box-shadow: 0 4px 12px -4px rgba(28, 37, 51, .5);
}

.blk-tag { gap: 7px; padding: 0 11px 0 9px; cursor: grab; }
.blk-tag i { opacity: .6; }
.blk.is-selected .blk-tag { background: var(--post); }

.blk-actions { padding: 0 3px; }

.blk-actions button {
    width: 24px;
    height: 22px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: rgba(245, 241, 234, .75);
    font-size: 11px;
    cursor: pointer;
}

.blk-actions button:hover { background: rgba(245, 241, 234, .15); color: #fff; }
.blk-actions button.is-danger:hover { background: var(--post); }

/* Block previews */

.pv-heading { margin: 0; font-weight: 700; outline: none; word-break: break-word; }
.pv-text { outline: none; word-break: break-word; }
.pv-text p { margin: 0 0 .75em; }
.pv-text ul, .pv-text ol { margin: 0 0 .75em 24px; padding: 0; }
.pv-text li { margin: 0 0 4px; }
.pv-text > :last-child { margin-bottom: 0; }
.pv-heading:focus, .pv-text:focus { box-shadow: 0 0 0 3px var(--air-soft); border-radius: 3px; }

.pv-image img { display: inline-block; max-width: 100%; width: 100%; height: auto; vertical-align: top; }
.pv-image img[style*="max-width"] { width: auto; }

.pv-image-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 48px 16px;
    background: repeating-linear-gradient(45deg, var(--ink-softer) 0 10px, transparent 10px 20px);
    color: var(--ink-3);
    font-family: var(--font-ui);
    font-size: 13px;
}

.pv-image-empty i { font-size: 26px; }

.pv-btn { box-sizing: border-box; text-align: center; text-decoration: none; max-width: 100%; }

.pv-divider { height: 0; margin: 0 auto; }

.pv-spacer {
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(-45deg, rgba(42, 77, 143, .06) 0 6px, transparent 6px 12px);
}

/* Columns: each column is a drop zone; nested blocks get a lighter outline and toolbar */
.pv-cols { display: flex; }
.pv-col { min-width: 0; }
.pv-cols.is-equal .pv-col { display: flex; flex-direction: column; justify-content: var(--col-align); }
.pv-cols.is-equal .col-drop { height: auto; }

.col-drop {
    min-height: 64px;
    height: 100%;
    border-radius: 4px;
    outline: 1px dashed rgba(42, 77, 143, .28);
    outline-offset: 2px;
}

.col-drop:empty {
    display: grid;
    place-items: center;
    background: rgba(42, 77, 143, .04);
}

.col-drop:empty::before {
    content: "Drop blocks here";
    font-family: var(--font-ui);
    font-size: 11.5px;
    font-weight: 700;
    color: rgba(42, 77, 143, .55);
}

.col-drop .blk-tools { top: -13px; left: 4px; right: 4px; }
.col-drop .blk-tag, .col-drop .blk-actions { height: 22px; font-size: 10.5px; }
.col-drop .blk-actions button { width: 20px; height: 18px; font-size: 10px; }
.col-drop .blk-tag { background: var(--air); }

.pv-spacer span { font-family: var(--font-ui); font-size: 10.5px; font-weight: 700; color: rgba(42, 77, 143, .55); }

/* Rich text toolbar */

.rte {
    position: fixed;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    border-radius: 12px;
    background: var(--ink);
    box-shadow: 0 10px 28px -8px rgba(28, 37, 51, .55);
}

.rte-rich { display: flex; align-items: center; gap: 2px; }
.rte.is-plain .rte-rich { display: none; }

.rte button {
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: rgba(245, 241, 234, .8);
    cursor: pointer;
}

.rte button:hover { background: rgba(245, 241, 234, .14); color: #fff; }

.rte-sep { width: 1px; height: 18px; margin: 0 3px; background: rgba(245, 241, 234, .18); }

.rte-color {
    position: relative;
    width: 30px;
    height: 30px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    color: rgba(245, 241, 234, .85);
    cursor: pointer;
    font-size: 13px;
}

.rte-color:hover { background: rgba(245, 241, 234, .14); }

.rte-color-bar {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 5px;
    height: 3px;
    border-radius: 2px;
    background: var(--post);
}

.rte-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.rte-select {
    height: 30px;
    padding: 0 6px;
    border: 0;
    border-radius: 8px;
    background: rgba(245, 241, 234, .08);
    color: var(--paper);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}

.rte-select option { color: var(--ink); background: #fff; }
.rte-tag { background: rgba(217, 71, 43, .35); }

/* Properties panel */

.ed-props {
    padding: 22px 20px 60px;
    overflow-y: auto;
    background: var(--card);
    border-left: 1px solid var(--line);
}

.props-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

.props-section { padding: 14px 0 6px; border-top: 1px dashed var(--line); margin-top: 6px; }
.props-section:first-of-type { border-top: 0; }

.props-section-title {
    margin: 2px 0 12px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.field { display: block; margin-bottom: 14px; }

.field-label { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }

.field-note { display: block; margin-top: 5px; font-size: 11.5px; color: var(--ink-3); }

.field-check { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; cursor: pointer; }
.field-check .field-note { flex-basis: 100%; margin: -4px 0 4px 26px; }
.field-check .field-label { margin: 0; }
.field-check input { width: 17px; height: 17px; accent-color: var(--post); }

.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.field-row .field { margin-bottom: 10px; }

.input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: #fff;
    font-size: 13.5px;
    transition: border-color .15s, box-shadow .15s;
}

.input:focus { outline: none; border-color: var(--air); box-shadow: 0 0 0 3px var(--air-soft); }

textarea.input { resize: vertical; min-height: 64px; }

.input-suffix { position: relative; }
.input-suffix .input { padding-right: 28px; }
.input-suffix span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--ink-3); pointer-events: none; }

.range { display: flex; align-items: center; gap: 10px; }
.range input { flex: 1; accent-color: var(--post); }
.range output { min-width: 44px; text-align: right; font-size: 12px; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.seg {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: 10px;
    background: var(--ink-soft);
}

.seg button {
    padding: 6px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink-2);
    cursor: pointer;
}

.seg button:hover { color: var(--ink); }
.seg button.is-on { background: #fff; color: var(--post); box-shadow: 0 1px 3px rgba(28, 37, 51, .15); }
.seg-icons button { width: 36px; padding: 6px 0; }

.color { position: relative; display: flex; align-items: center; gap: 8px; }

.color input[type="color"] {
    width: 38px;
    height: 36px;
    flex: none;
    padding: 3px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius-sm);
    background: #fff;
    cursor: pointer;
}

.color.is-empty input[type="color"] {
    background: repeating-linear-gradient(45deg, #fff 0 4px, var(--paper-3) 4px 8px);
}

.color.is-empty input[type="color"]::-webkit-color-swatch { opacity: 0; }

.color .input { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

.color-clear {
    position: absolute;
    right: 6px;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
}

.color-clear:hover { background: var(--ink-soft); color: var(--ink); }

.tag-input { display: flex; gap: 6px; }
.tag-input .input { flex: 1; min-width: 0; }

.tag-pick {
    width: 44px;
    flex: none;
    border: 1px solid rgba(217, 71, 43, .25);
    border-radius: var(--radius-sm);
    background: var(--post-softer);
    color: var(--post);
    font-weight: 800;
    text-align: center;
    cursor: pointer;
}

/* ---------- Modals ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(28, 37, 51, .55);
    backdrop-filter: blur(3px);
}

.modal-card {
    width: min(760px, 100%);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5);
    overflow: hidden;
}

.modal-wide { width: min(1000px, 100%); height: calc(100vh - 48px); }
.modal-narrow { width: min(480px, 100%); }

/* Version history */
.history { flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr); }

.history-list {
    list-style: none;
    margin: 0;
    padding: 10px;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: var(--paper);
}

.history-list li {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
}

.history-list li:hover { background: var(--ink-softer); }
.history-list li.is-on { background: var(--card); border-color: rgba(217, 71, 43, .35); box-shadow: 0 4px 12px -8px rgba(28, 37, 51, .35); }
.history-list li strong { font-size: 13.5px; }
.history-list li small { font-size: 12px; color: var(--ink-3); }
.history-list li.history-empty { cursor: default; color: var(--ink-3); font-size: 13px; }

.history-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--sage-soft);
    color: var(--sage);
    font-size: 11px;
    font-weight: 700;
}

.history-preview { display: flex; flex-direction: column; min-height: 0; background: var(--paper-2); }

.history-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    background: var(--card);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
}

#historyFrame { flex: 1; width: 100%; border: 0; background: #fff; }

@media (max-width: 760px) {
    .history { grid-template-columns: 1fr; grid-template-rows: 180px 1fr; }
    .history-list { border-right: 0; border-bottom: 1px solid var(--line); }
}
.modal-body { padding: 20px 18px 6px; overflow-y: auto; }
.modal-body .field-check { margin-bottom: 16px; }
.modal-body .alert { margin: 0 0 14px; }

.modal-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}

.modal-head h3 { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.modal-head h3 i { color: var(--post); font-size: 16px; margin-right: 4px; }
.modal-head .btn-icon { margin-left: auto; }

.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }

.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.toggle input { accent-color: var(--post); width: 16px; height: 16px; }

.preview-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    justify-content: center;
    padding: 20px;
    background: var(--paper-2);
    overflow: auto;
}

#previewFrame {
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 6px;
    background: #fff;
    box-shadow: var(--shadow);
    transition: width .3s ease;
}

#previewFrame.is-mobile {
    width: 375px;
    flex: none;
    border-radius: 28px;
    border: 10px solid var(--ink);
}

.export-code {
    width: 100%;
    height: 52vh;
    margin: 0;
    padding: 16px 18px;
    border: 0;
    resize: none;
    background: #1f2836;
    color: #e6dccb;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
    line-height: 1.55;
}

.size-badge {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--sage-soft);
    color: var(--sage);
}

.size-badge[data-kind="warn"] { background: var(--post-soft); color: var(--post); }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .ed-body { grid-template-columns: 76px minmax(0, 1fr) 290px; }
    .ed-palette { padding: 16px 10px; }
    .ed-palette .panel-title, .ed-palette .panel-hint, .palette-text, .palette-grip { display: none; }
    .palette-item { justify-content: center; padding: 10px 0; }
}

@media (max-width: 900px) {
    .auth { grid-template-columns: 1fr; gap: 32px; padding-top: 36px; }
}

@media (max-width: 760px) {
    .masthead-inner, .library, .auth { padding-left: 16px; padding-right: 16px; }
    .user-name { display: none; }
    .user-chip { padding-right: 4px; }
    .envelope { padding: 30px 20px 24px; }
    .library { padding-top: 32px; }
    .library-head { flex-direction: column; align-items: flex-start; }
    .ed { height: auto; }
    .ed-bar { flex-wrap: wrap; }
    .ed-bar-actions { width: 100%; margin-left: 0; }
    .ed-bar-actions .btn { flex: 1; padding-left: 8px; padding-right: 8px; }
    .ed-body { display: block; }
    .ed-palette { border-right: 0; border-bottom: 1px solid var(--line); }
    .ed-palette .palette { grid-template-columns: repeat(6, 1fr); }
    .ed-desk { padding: 28px 12px 60px; }
    .ed-props { border-left: 0; border-top: 1px solid var(--line); }
    .sitefoot-inner { padding-left: 16px; padding-right: 16px; }
}
