/* Design editor (poster, flyer, invitation, social post, presentation and logo makers). */
.de {
    --de-w: min(1520px, calc(100vw - 56px));
    --de-sel: #8B5CF6;
    position: relative; display: flex; flex-direction: column;
    width: var(--de-w); margin: 0 0 28px calc((100% - var(--de-w)) / 2);
    height: clamp(620px, calc(100dvh - 110px), 1040px);
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--shadow-2); overflow: hidden;
}
@media (min-width: 1100px) { .de { --de-w: min(1520px, calc(100vw - var(--side-w) - 56px)); } }
.de [hidden] { display: none !important; }
.de.is-full { position: fixed; inset: 0; z-index: 80; width: auto; height: 100dvh; margin: 0; border: 0; border-radius: 0; }
html.de-full-open { overflow: hidden; }

/* ---------- Buttons ---------- */
.de-ibtn {
    display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 8px;
    background: none; color: var(--ink); cursor: pointer;
}
.de-ibtn .icon { width: 18px; height: 18px; }
.de-ibtn:hover:not(:disabled) { background: var(--mist); }
.de-ibtn:disabled { opacity: 0.35; cursor: default; }
.de-ibtn[aria-pressed="true"] { background: #F1EBFF; color: #5B21B6; }
.de-danger:hover:not(:disabled) { background: var(--bad-soft); color: var(--bad); }
.de-tbtn {
    display: inline-flex; align-items: center; gap: 7px; flex: none; height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--paper); color: var(--ink); font: 500 0.88rem var(--text); white-space: nowrap; cursor: pointer;
}
.de-tbtn .icon { width: 16px; height: 16px; }
.de-tbtn:hover, .de-tbtn[aria-expanded="true"] { border-color: var(--line-strong); background: var(--canvas); }
.de-chip-color { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(15 29 58 / 0.18); }
.de-link { display: inline-block; margin-top: 10px; padding: 0; border: 0; background: none; color: var(--signal-ink); font: 500 0.9rem var(--text); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.de-wide { width: 100%; justify-content: center; }
.de :focus-visible { outline: 2px solid var(--de-sel); outline-offset: 1px; }

/* ---------- Top bar ---------- */
.de-top { display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 12px; border-bottom: 1px solid var(--line); }
.de .de-name {
    width: min(280px, 34vw); min-width: 0; padding: 6px 9px; border: 1px solid transparent; border-radius: 8px; background: none;
    color: var(--ink); font: 600 1rem var(--display);
}
.de .de-name:hover { border-color: var(--line); }
.de .de-name:focus { border-color: var(--de-sel); outline: none; background: var(--paper); box-shadow: none; }
.de-size { color: var(--slate); font-size: 0.86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.de-saved { color: var(--slate-2); font-size: 0.82rem; white-space: nowrap; }
.de-spacer { flex: 1; }

/* ---------- Main area ---------- */
.de-main { position: relative; flex: 1; display: flex; min-height: 0; }
.de-rail {
    display: flex; flex-direction: column; gap: 2px; flex: none; width: 78px; padding: 8px 6px; border-right: 1px solid var(--line);
    background: var(--paper); overflow-y: auto;
}
.de-rail button {
    display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px 8px; border: 0; border-radius: 10px;
    background: none; color: var(--slate); font: 500 0.72rem var(--text); cursor: pointer;
}
.de-rail .icon { width: 22px; height: 22px; }
.de-rail button:hover { background: var(--canvas); color: var(--ink); }
.de-rail button[aria-pressed="true"] { background: #F1EBFF; color: #5B21B6; }

.de-drawer { display: flex; flex-direction: column; flex: none; width: 330px; border-right: 1px solid var(--line); background: var(--paper); overflow-y: auto; }
.de-drawer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 16px; background: var(--paper); }
.de-drawer-head strong { font: 700 1.02rem var(--display); }
.de-panel { padding: 0 16px 20px; }
.de-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 18px 0 8px; font-weight: 600; font-size: 0.86rem; color: var(--ink); }
.de-label span { color: var(--slate-2); font-weight: 400; font-size: 0.78rem; text-align: right; }
.de-note { margin: 8px 0 12px; color: var(--slate); font-size: 0.84rem; line-height: 1.45; }
.de .de-search { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 0.92rem; background: var(--canvas); }
.de .de-search:focus { outline: none; border-color: var(--de-sel); background: var(--paper); }

.de-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.de-chip { padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink); font: 500 0.82rem var(--text); cursor: pointer; }
.de-chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.de-tpls { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 10px; }
.de-tpls li { break-inside: avoid; margin-bottom: 10px; }
.de-tpls button { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.de-tpls img { display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); background: var(--mist); }
.de-tpls button:hover img { box-shadow: 0 0 0 2px var(--de-sel); }
.de-tpls span { display: block; padding: 5px 2px 0; font-size: 0.8rem; color: var(--slate); }

.de-add-text {
    display: block; width: 100%; margin-bottom: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--canvas); color: var(--ink); text-align: left; cursor: pointer; font-family: Montserrat, var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.de-add-text:hover { border-color: var(--line-strong); background: var(--paper); }
.de-add-h { font-size: 1.5rem; font-weight: 800; }
.de-add-s { font-size: 1.1rem; font-weight: 700; }
.de-add-b { font-size: 0.88rem; }
.de-combos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.de-combo {
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 2px; min-height: 92px; padding: 10px 6px; border: 1px solid var(--line);
    border-radius: 10px; background: var(--canvas); color: var(--ink); line-height: 1.1; text-align: center; cursor: pointer; overflow: hidden;
}
.de-combo:hover { border-color: var(--de-sel); background: var(--paper); }
.de-combo span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.de-shapes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.de-shapes button { display: grid; place-items: center; aspect-ratio: 1; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); cursor: pointer; }
.de-shapes button:hover { border-color: var(--de-sel); background: var(--paper); }
.de-shapes svg { width: 100%; height: 100%; fill: #55627A; }
.de-shapes svg.is-frame { fill: #DCE3EC; stroke: #8B97AA; stroke-width: 1.5; stroke-dasharray: 3 2.5; }
.de-icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; margin-top: 10px; color: var(--slate); font-size: 0.86rem; }
.de-icons button { display: grid; place-items: center; aspect-ratio: 1; border: 0; border-radius: 8px; background: none; color: var(--ink); cursor: pointer; }
.de-icons button:hover { background: var(--mist); }
.de-icons svg { width: 26px; height: 26px; }

.de-uploads { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.de-upload { padding: 0; border: 0; border-radius: 8px; overflow: hidden; aspect-ratio: 1; background: var(--mist); cursor: pointer; }
.de-upload img { width: 100%; height: 100%; object-fit: cover; display: block; }
.de-upload:hover { box-shadow: 0 0 0 2px var(--de-sel); }

.de-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(30px, 1fr)); gap: 7px; }
.de-swatch { aspect-ratio: 1; padding: 0; border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(15 29 58 / 0.16); cursor: pointer; }
.de-swatch:hover { box-shadow: inset 0 0 0 1px rgb(15 29 58 / 0.16), 0 0 0 2px var(--paper), 0 0 0 4px var(--de-sel); }
.de-panel .btn + .btn { margin-top: 8px; }

.de-brand-logo { display: grid; place-items: center; width: 100%; height: 110px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); cursor: pointer; }
.de-brand-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.de-brand-logo:hover { border-color: var(--de-sel); }
#de-brand .btn { margin-top: 10px; }

.de-designs { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.de-designs li { display: flex; align-items: center; gap: 4px; border-radius: 10px; }
.de-designs li.is-on { background: #F6F2FF; }
.de-design { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 6px; border: 0; border-radius: 10px; background: none; color: var(--ink); text-align: left; cursor: pointer; }
.de-design:hover { background: var(--canvas); }
.de-design-thumb { display: grid; place-items: center; flex: none; width: 54px; height: 54px; border-radius: 6px; background: var(--mist); overflow: hidden; }
.de-design-thumb img { max-width: 100%; max-height: 100%; }
.de-design strong { display: block; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.de-design small { color: var(--slate); font-size: 0.78rem; }

/* Magic design */
.de-panel[data-panel="magic"] .field { margin-bottom: 10px; }
.de-panel[data-panel="magic"] .field label { font-size: 0.84rem; }
.de-panel[data-panel="magic"] .de-link { display: block; margin: 8px auto 0; }
.de-mg-progress { margin-top: 12px; }
.de-mg-privacy { margin-top: 12px; font-size: 0.78rem; }
.de-mg-fields { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.de-mg-results { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; align-items: start; }
.de-mg-results > p { grid-column: 1 / -1; margin: 0; }
.de-mg-result { display: block; padding: 0; border: 0; background: none; cursor: pointer; }
.de-mg-result img { display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: 0 0 0 1px var(--line); }
.de-mg-result:hover img { box-shadow: 0 0 0 2px var(--de-sel); }

/* ---------- Work area ---------- */
.de-work { position: relative; flex: 1; display: flex; flex-direction: column; min-width: 0; background: #ECEFF4; }
.de-ctx {
    display: flex; align-items: center; gap: 6px; min-height: 52px; padding: 8px 10px; border-bottom: 1px solid var(--line);
    background: var(--paper); overflow-x: auto; scrollbar-width: none;
}
.de-ctx::-webkit-scrollbar { display: none; }
.de-ctx-group { display: flex; align-items: center; gap: 4px; flex: none; }
.de-ctx-end { margin-left: auto; padding-left: 10px; }
.de-ctx-hint { color: var(--slate); font-size: 0.86rem; white-space: nowrap; padding: 0 6px; }
.de-font-btn { width: 168px; justify-content: space-between; }
.de-font-btn span { overflow: hidden; text-overflow: ellipsis; }
.de-num { display: inline-flex; align-items: center; height: 34px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.de-num button { display: grid; place-items: center; width: 28px; height: 100%; border: 0; background: none; color: var(--ink); cursor: pointer; }
.de-num button:hover { background: var(--canvas); }
.de-num .icon { width: 14px; height: 14px; }
.de .de-num input { width: 46px; height: 100%; padding: 0; border-radius: 0; box-shadow: none; border: 0; border-inline: 1px solid var(--line); text-align: center; font: 500 0.9rem var(--text); -moz-appearance: textfield; }
.de-num input::-webkit-inner-spin-button { display: none; }
.de-text-color { flex-direction: column; justify-content: center; gap: 0; width: 34px; padding: 0; }
.de-text-color span { font: 700 1rem/1 var(--display); }
.de-text-color i { width: 18px; height: 4px; margin-top: 2px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgb(15 29 58 / 0.18); }
.de-case { font: 600 0.9rem var(--text); }
.de-range-inline { display: inline-flex; align-items: center; gap: 8px; font-size: 0.86rem; color: var(--slate); }
.de-range-inline input { width: 100px; accent-color: var(--de-sel); }

.de-stage { position: relative; flex: 1; display: grid; place-items: center; overflow: auto; padding: 24px; min-height: 0; }
.de-stage.is-drop { outline: 3px dashed var(--de-sel); outline-offset: -10px; }
.de-paper { line-height: 0; background: #fff; box-shadow: 0 1px 3px rgb(15 29 58 / 0.12), 0 12px 32px -12px rgb(15 29 58 / 0.25); }
.de-paper.is-clear { background: repeating-conic-gradient(#E3E7EE 0 25%, #fff 0 50%) 0 0 / 20px 20px; }
.de-loading { position: absolute; inset: 0; display: grid; place-items: center; background: #ECEFF4; color: var(--slate); font-weight: 500; }

.de-bottom { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--line); background: var(--paper); }
.de-pages { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; overflow-x: auto; padding: 2px; scrollbar-width: thin; }
.de-thumb { position: relative; flex: none; height: 58px; padding: 0; border: 2px solid var(--line); border-radius: 6px; background: #fff; overflow: hidden; cursor: pointer; }
.de-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.de-thumb span { position: absolute; left: 3px; bottom: 3px; min-width: 16px; padding: 0 4px; border-radius: 4px; background: rgb(15 29 58 / 0.7); color: #fff; font-size: 0.68rem; line-height: 16px; }
.de-thumb.is-on { border-color: var(--de-sel); }
.de-page-actions { display: flex; align-items: center; gap: 2px; flex: none; padding-left: 4px; }
.de-zoom { display: flex; align-items: center; gap: 2px; flex: none; }
.de-zoom-label { min-width: 54px; height: 30px; border: 0; border-radius: 6px; background: none; color: var(--ink); font: 500 0.86rem var(--text); cursor: pointer; }
.de-zoom-label:hover { background: var(--mist); }

/* ---------- Pop-overs ---------- */
.de-pop-share { width: 320px; }
.de:not([data-kind="invitation"]) .de-rsvp-btn { display: none; }
.de-pop-rsvp { width: 360px; }
.de-rsvp-form { display: flex; flex-direction: column; gap: 10px; }
.de-rsvp-form .field { margin: 0; }
.de-rsvp-form .field label { font-size: 0.84rem; }
#de-rsvp-on { display: flex; flex-direction: column; gap: 10px; }
#de-rsvp-on .de-row { margin: 0; }
.de-rsvp-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.de-rsvp-totals div { padding: 8px; border-radius: 10px; background: var(--canvas); text-align: center; }
.de-rsvp-totals strong { display: block; font: 700 1.3rem var(--display); }
.de-rsvp-totals span { color: var(--slate); font-size: 0.76rem; }
.de-rsvp-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; border-top: 1px solid var(--line); }
.de-rsvp-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.de-rsvp-list small { grid-column: 1 / -1; color: var(--slate); }
.de-rsvp-list .is-yes { color: var(--good); font-weight: 600; }
.de-rsvp-list .is-no { color: var(--bad); font-weight: 600; }
.de-rsvp-list .is-maybe { color: var(--warn); font-weight: 600; }
.de-rsvp-links { display: flex; justify-content: space-between; }
.de-rsvp-links .de-link { margin: 0; }
.de-danger-link { color: var(--bad); }
.de .de-share-url { flex: 1; min-width: 0; padding: 7px 9px; font-size: 0.84rem; border: 1px solid var(--line); border-radius: 8px; background: var(--canvas); }
.de-pop {
    position: absolute; z-index: 60; width: 280px; max-height: min(70vh, 520px); overflow-y: auto; padding: 14px; border: 1px solid var(--line);
    border-radius: 12px; background: var(--paper); box-shadow: var(--shadow-3);
}
.de-pop .field { margin-bottom: 12px; }
.de-pop .checkbox { display: flex; margin: 4px 0 12px; font-size: 0.92rem; }
.de-pop-title { margin: 10px 0 8px; font-weight: 600; font-size: 0.82rem; color: var(--slate); }
.de-pop-title:first-child { margin-top: 0; }
.de-pop-font { width: 270px; padding: 10px; }
.de-font-list { max-height: 340px; overflow-y: auto; margin-top: 8px; }
.de-font { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 6px; background: none; color: var(--ink); font-size: 1.12rem; text-align: left; cursor: pointer; }
.de-font:hover { background: var(--canvas); }
.de-font.is-on { background: #F1EBFF; }
.de-custom-color { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-weight: 500; font-size: 0.9rem; cursor: pointer; }
.de .de-custom-color input { width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.de-range { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; margin-bottom: 12px; font-weight: 500; font-size: 0.9rem; }
.de-range output { color: var(--slate); font-variant-numeric: tabular-nums; }
.de-range input { grid-column: 1 / -1; width: 100%; accent-color: var(--de-sel); }
.de-row { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.de-row input[type="range"] { flex: 1; accent-color: var(--de-sel); }
.de .de-row input[type="number"] { width: 90px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.de-grid2, .de-grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.de-grid3 { grid-template-columns: 1fr 1fr 1fr; }
.de-grid2 .de-tbtn, .de-grid3 .de-tbtn { justify-content: center; padding: 0 6px; }
.de-pop-new { width: min(560px, calc(100% - 16px)); }
.de-formats > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.de-formats .de-label { grid-column: 1 / -1; margin: 12px 0 2px; }
.de-formats > div:first-child .de-label { margin-top: 0; }
.de-format {
    display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 0 10px; padding: 8px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--paper); color: var(--ink); text-align: left; cursor: pointer;
}
.de-format:hover { border-color: var(--de-sel); background: #FAF8FF; }
.de-format-box { grid-row: span 2; justify-self: center; max-width: 30px; max-height: 30px; width: 30px; border: 2px solid var(--ink); border-radius: 3px; }
.de-format span:nth-child(2) { font-weight: 600; font-size: 0.86rem; line-height: 1.25; }
.de-format small { color: var(--slate); font-size: 0.74rem; }
.de-custom { margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--line); }

.de-status:empty { display: none; }
.de-status {
    position: absolute; left: 50%; bottom: 84px; z-index: 55; transform: translateX(-50%); max-width: calc(100% - 32px); margin: 0;
    padding: 8px 14px; border-radius: 10px; background: var(--ink); color: #fff; font-size: 0.88rem; box-shadow: var(--shadow-3);
}

/* ---------- Phones and small tablets: the rail becomes a bottom bar and panels slide up over the page ---------- */
@media (max-width: 899px) {
    .de { --de-w: calc(100% + 40px); margin-left: -20px; height: calc(100dvh - var(--tabbar-h, 0px) - 70px); min-height: 520px; border-radius: 0; border-inline: 0; box-shadow: none; }
    .de.is-full { height: 100dvh; }
    .de-hide-sm, .de-size, .de-ctx-hint { display: none !important; }
    .de-name { width: auto; flex: 1; }
    .de-main { flex-direction: column; }
    .de-work { order: 1; }
    .de-rail { order: 3; flex-direction: row; width: auto; padding: 4px 6px; border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; }
    .de-rail button { flex: 1 0 62px; padding: 6px 2px; }
    .de-rail .icon { width: 20px; height: 20px; }
    .de-drawer {
        order: 2; position: absolute; left: 0; right: 0; bottom: 62px; z-index: 50; width: auto; max-height: 58%;
        border: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -12px 32px -12px rgb(15 29 58 / 0.3);
    }
    .de-stage { padding: 14px; }
    .de-thumb { height: 44px; }
    .de-bottom { padding: 6px 8px; }
    .de-font-btn { width: 132px; }
    .de-pop { max-width: calc(100% - 16px); }
    .de-status { bottom: 120px; }
}
@media (max-width: 600px) {
    .de { --de-w: calc(100% + 32px); margin-left: -16px; }
}
.de-mg-progress .progress { background: var(--mist); }
