/*
|--------------------------------------------------------------------------
| Save the Date designer — classic-modern Astra styling
|--------------------------------------------------------------------------
| The Astra Save the Date designer: a Templates rail, an Elements
| add-bar, a per-element Properties panel with layer controls, a multi-page
| canvas and a PNG export. Ivory canvas, charcoal text, champagne/gold accents.
*/

:root {
    --dz-gold: #b89766;
    --dz-gold-deep: #a07f4f;
    --dz-ink: #23201c;
    --dz-text: #2c2a27;
    --dz-muted: #6f675b;
    --dz-line: rgba(35, 32, 28, .14);
    --dz-panel: #fffdf9;
    --dz-bg: #f3efe6;
    --dz-canvas: #fffef9;
    --dz-serif: "Playfair Display", "Cormorant Garamond", Georgia, serif;
    --dz-rail: 268px;
    --dz-props: 280px;
    --dz-top: 64px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body.dz-body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, sans-serif;
    color: var(--dz-text);
    background:
        radial-gradient(circle at 12% 0%, rgba(184, 151, 102, .08), transparent 32%),
        linear-gradient(180deg, #faf7f2 0%, #f4f0e7 100%);
    overflow: hidden;
}

/* ---------------------------------------------------------------- Top bar */
.dz-top {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--dz-top);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 18px;
    background: rgba(255, 253, 249, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--dz-line);
    z-index: 40;
}
.dz-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--dz-ink); }
.dz-brand img { width: 40px; height: 40px; }
.dz-brand b { font-family: var(--dz-serif); font-size: 1.02rem; display: block; line-height: 1.05; }
.dz-brand span { font-size: .56rem; letter-spacing: .2em; text-transform: uppercase; color: var(--dz-muted); }
.dz-title { font-family: var(--dz-serif); color: var(--dz-ink); font-size: 1.05rem; font-weight: 600; }
.dz-title small { display: block; font-family: Inter, sans-serif; font-size: .64rem; letter-spacing: .16em; text-transform: uppercase; color: var(--dz-gold-deep); font-weight: 600; }
.dz-top .dz-spacer { flex: 1; }

.dz-hint {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: .76rem; color: var(--dz-muted);
    background: rgba(184, 151, 102, .1);
    border: 1px solid rgba(184, 151, 102, .28);
    padding: 6px 12px; border-radius: 999px; white-space: nowrap;
}
.dz-hint b { color: var(--dz-gold-deep); font-weight: 600; }

.dz-btn {
    appearance: none; border: none; cursor: pointer; font: inherit;
    font-weight: 600; font-size: .86rem; padding: 10px 18px; border-radius: 999px;
    transition: .16s; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.dz-btn.primary { background: linear-gradient(135deg, var(--dz-gold), var(--dz-gold-deep)); color: #fff; box-shadow: 0 8px 20px rgba(184, 151, 102, .3); }
.dz-btn.primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px rgba(184, 151, 102, .4); }
.dz-btn.ghost { background: #fff; color: var(--dz-ink); border: 1px solid var(--dz-line); }
.dz-btn.ghost:hover { border-color: var(--dz-gold); color: var(--dz-gold-deep); }
.dz-btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------------------------------------------------------------- Layout */
.dz-stage {
    position: fixed;
    inset: var(--dz-top) 0 0 0;
    display: grid;
    grid-template-columns: var(--dz-rail) 1fr var(--dz-props);
    /* Pin the single row to the stage height. Without this the implicit row is
       auto-sized to its tallest child, so the columns grow past the fixed
       stage instead of scrolling inside it. */
    grid-template-rows: 100%;
    overflow: hidden;
}
/* min-height:0 lets a grid/flex child shrink below its content height. Without
   it the panels size to their content, their own overflow-y never engages, and
   because body is overflow:hidden the excess is simply clipped and
   unreachable — which is what made the editor unscrollable on short viewports
   once the properties panel gained a few more controls. */
.dz-left, .dz-right, .dz-canvas-area { min-height: 0; }
.dz-left, .dz-right { background: var(--dz-panel); overflow-y: auto; }
.dz-left { border-right: 1px solid var(--dz-line); }
.dz-right { border-left: 1px solid var(--dz-line); }

/* ---------------------------------------------------------- Left rail tabs */
.dz-tabs { display: flex; gap: 6px; padding: 14px 14px 0; position: sticky; top: 0; background: var(--dz-panel); z-index: 2; }
.dz-tab {
    flex: 1; appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: .8rem;
    padding: 9px 8px; border-radius: 10px 10px 0 0; border: 1px solid transparent;
    background: transparent; color: var(--dz-muted);
}
.dz-tab.is-active { color: var(--dz-ink); background: #fff; border-color: var(--dz-line); border-bottom-color: #fff; }
.dz-tabpanel { display: none; padding: 16px 14px 30px; }
.dz-tabpanel.is-active { display: block; }

.dz-section-label { font-size: .68rem; letter-spacing: .16em; text-transform: uppercase; color: var(--dz-gold-deep); font-weight: 700; margin: 6px 0 10px; }

/* Template filters */
.dz-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.dz-filter {
    appearance: none; cursor: pointer; font: inherit; font-size: .74rem; font-weight: 600;
    padding: 6px 12px; border-radius: 999px; border: 1px solid var(--dz-line);
    background: #fff; color: var(--dz-muted); transition: .14s;
}
.dz-filter:hover { border-color: var(--dz-gold); color: var(--dz-gold-deep); }
.dz-filter.is-active { background: linear-gradient(135deg, var(--dz-gold), var(--dz-gold-deep)); color: #fff; border-color: transparent; }

.dz-templates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dz-tpl { border: 1px solid var(--dz-line); border-radius: 12px; overflow: hidden; background: #fff; cursor: pointer; transition: .16s; }
.dz-tpl:hover { border-color: var(--dz-gold); box-shadow: 0 8px 20px rgba(43, 38, 28, .1); transform: translateY(-2px); }
.dz-tpl-prev { aspect-ratio: 3/4; background: var(--dz-canvas); position: relative; overflow: hidden; }
.dz-tpl-prev svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dz-tpl-foot { display: flex; align-items: center; justify-content: space-between; padding: 7px 9px; gap: 6px; }
.dz-tpl-foot span { font-size: .72rem; color: var(--dz-ink); font-weight: 600; }
.dz-tpl-foot em { font-size: .72rem; font-style: normal; color: var(--dz-gold-deep); font-weight: 700; }

/* Add-element buttons */
.dz-add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dz-add {
    appearance: none; cursor: pointer; font: inherit; font-weight: 600; font-size: .82rem;
    display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
    padding: 16px 8px; border-radius: 12px; border: 1px solid var(--dz-line); background: #fff;
    color: var(--dz-ink); transition: .16s;
}
.dz-add:hover { border-color: var(--dz-gold); color: var(--dz-gold-deep); box-shadow: 0 8px 18px rgba(43, 38, 28, .08); transform: translateY(-2px); }
.dz-add svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.dz-add.full { grid-column: 1 / -1; flex-direction: row; justify-content: center; }

.dz-subtle { font-size: .76rem; color: var(--dz-muted); line-height: 1.5; margin: 14px 0 0; }

/* ------------------------------------------------------------ Canvas area */
.dz-canvas-area { display: flex; flex-direction: column; min-width: 0; }

/* Undo/redo bar above the page strip. */
.dz-history {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0 0 8px;
}
.dz-history .dz-mini[disabled] { opacity: .4; cursor: not-allowed; }
.dz-shortcut-hint { margin-inline-start: auto; font-size: 11px; }
@media (max-width: 720px) {
    .dz-shortcut-hint { display: none; }
}
.dz-pages {
    display: flex; align-items: center; gap: 8px; padding: 12px 16px; overflow-x: auto;
    border-bottom: 1px solid var(--dz-line); background: rgba(255, 253, 249, .6);
}
.dz-page-tab {
    appearance: none; cursor: pointer; font: inherit; font-size: .78rem; font-weight: 600;
    padding: 7px 14px; border-radius: 999px; border: 1px solid var(--dz-line);
    background: #fff; color: var(--dz-muted); white-space: nowrap; transition: .14s;
}
.dz-page-tab.is-active { background: var(--dz-ink); color: #fff; border-color: var(--dz-ink); }
.dz-page-tab .x { margin-left: 7px; opacity: .65; }
.dz-page-tab .x:hover { opacity: 1; }
.dz-add-page {
    appearance: none; cursor: pointer; font: inherit; font-size: .8rem; font-weight: 700;
    width: 32px; height: 32px; border-radius: 50%; border: 1px dashed var(--dz-gold);
    background: #fff; color: var(--dz-gold-deep); transition: .14s; flex: 0 0 auto;
}
.dz-add-page:hover { background: rgba(184, 151, 102, .12); }

.dz-canvas-scroll { flex: 1; overflow: auto; display: grid; place-items: center; padding: 30px; }
.dz-canvas-shell {
    box-shadow: 0 24px 60px rgba(43, 38, 28, .22);
    border-radius: 4px; background: var(--dz-canvas); line-height: 0;
}
.dz-canvas-shell .canvas-container { border-radius: 4px; }

/* --------------------------------------------------------- Properties */
.dz-props-wrap { padding: 18px 16px 40px; }
.dz-props-empty { color: var(--dz-muted); font-size: .85rem; line-height: 1.6; text-align: center; padding: 40px 8px; }
.dz-props-empty svg { width: 40px; height: 40px; stroke: var(--dz-line); fill: none; stroke-width: 1.4; margin-bottom: 12px; }
.dz-props-body { display: none; }
.dz-props-body.is-active { display: block; }

.dz-field { margin-bottom: 16px; }
.dz-field > label { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--dz-muted); margin-bottom: 7px; }
.dz-field select, .dz-field input[type="number"], .dz-field input[type="text"] {
    width: 100%; padding: 10px 12px; border: 1px solid var(--dz-line); border-radius: 10px;
    background: #fff; color: var(--dz-text); font: inherit; font-size: .88rem;
}
.dz-field select:focus, .dz-field input:focus { outline: none; border-color: var(--dz-gold); box-shadow: 0 0 0 3px rgba(184, 151, 102, .15); }

.dz-row { display: flex; gap: 10px; }
.dz-row > * { flex: 1; }

.dz-color-row { display: flex; align-items: center; gap: 10px; }
.dz-color-row input[type="color"] { width: 46px; height: 38px; padding: 0; border: 1px solid var(--dz-line); border-radius: 10px; background: #fff; cursor: pointer; }
.dz-color-row .val { font-size: .82rem; color: var(--dz-muted); font-variant-numeric: tabular-nums; }

.dz-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.dz-mini {
    appearance: none; cursor: pointer; font: inherit; font-size: .76rem; font-weight: 600;
    padding: 9px 10px; border-radius: 9px; border: 1px solid var(--dz-line); background: #fff;
    color: var(--dz-ink); transition: .14s; display: inline-flex; align-items: center; gap: 6px;
}
.dz-mini:hover { border-color: var(--dz-gold); color: var(--dz-gold-deep); }
.dz-mini svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.dz-mini.danger { color: #b3261e; }
.dz-mini.danger:hover { border-color: #e0a9a4; background: #fdeceb; }
.dz-layer-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dz-layer-grid .dz-mini { justify-content: center; }

.dz-style-toggles { display: flex; gap: 8px; }
.dz-toggle {
    appearance: none; cursor: pointer; font: inherit; font-size: .9rem; font-weight: 700;
    width: 40px; height: 38px; border-radius: 10px; border: 1px solid var(--dz-line);
    background: #fff; color: var(--dz-ink); transition: .14s;
}
.dz-toggle.is-on { background: var(--dz-ink); color: #fff; border-color: var(--dz-ink); }
.dz-toggle:hover { border-color: var(--dz-gold); }

/* ----------------------------------------------------------------- Modals */
.dz-modal {
    position: fixed; inset: 0; z-index: 60; display: none;
    align-items: center; justify-content: center; padding: 20px;
    background: rgba(35, 32, 28, .5); backdrop-filter: blur(3px);
}
.dz-modal.is-open { display: flex; }
.dz-modal-card {
    background: var(--dz-panel); border-radius: 20px; border: 1px solid var(--dz-line);
    box-shadow: 0 30px 70px rgba(43, 38, 28, .3); width: 100%; max-width: 460px;
    max-height: 90vh; overflow-y: auto; padding: 26px;
}
.dz-modal-card.wide { max-width: 540px; }
.dz-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.dz-modal-head h2 { font-family: var(--dz-serif); color: var(--dz-ink); font-weight: 600; font-size: 1.4rem; margin: 0; }
.dz-modal-head p { color: var(--dz-muted); font-size: .85rem; margin: 4px 0 0; }
.dz-x { appearance: none; cursor: pointer; border: none; background: transparent; color: var(--dz-muted); font-size: 1.5rem; line-height: 1; padding: 0 4px; }
.dz-x:hover { color: var(--dz-ink); }

.dz-icon-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.dz-icon-pick {
    appearance: none; cursor: pointer; aspect-ratio: 1; border-radius: 12px;
    border: 1px solid var(--dz-line); background: #fff; display: grid; place-items: center;
    color: var(--dz-ink); transition: .14s; padding: 12px;
}
.dz-icon-pick:hover { border-color: var(--dz-gold); color: var(--dz-gold-deep); background: rgba(184, 151, 102, .08); transform: translateY(-2px); }
.dz-icon-pick svg { width: 100%; height: 100%; }

/* Save form */
.dz-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dz-form-grid .full { grid-column: 1 / -1; }
.dz-form-grid label { display: block; font-size: .76rem; font-weight: 600; color: var(--dz-ink); margin-bottom: 6px; }
.dz-form-grid label em { color: var(--dz-muted); font-style: normal; font-weight: 400; }
.dz-form-grid input {
    width: 100%; padding: 10px 12px; border: 1px solid var(--dz-line); border-radius: 10px;
    background: #fff; color: var(--dz-text); font: inherit; font-size: .9rem;
}
.dz-form-grid input:focus { outline: none; border-color: var(--dz-gold); box-shadow: 0 0 0 3px rgba(184, 151, 102, .15); }
.dz-slug { display: flex; align-items: stretch; border: 1px solid var(--dz-line); border-radius: 10px; overflow: hidden; background: #fff; }
.dz-slug:focus-within { border-color: var(--dz-gold); box-shadow: 0 0 0 3px rgba(184, 151, 102, .15); }
.dz-slug .pfx { display: flex; align-items: center; padding: 0 9px; background: #f4eee2; color: var(--dz-muted); font-size: .78rem; border-right: 1px solid var(--dz-line); white-space: nowrap; }
.dz-slug input { border: none; box-shadow: none !important; border-radius: 0; }
.dz-form-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.dz-err { color: #b3261e; font-size: .76rem; margin-top: 5px; display: none; }
.dz-err.is-shown { display: block; }
.dz-form-errors { background: #fdeceb; border: 1px solid #f4c7c3; color: #8a1c13; border-radius: 12px; padding: 11px 14px; margin-bottom: 16px; font-size: .85rem; display: none; }
.dz-form-errors.is-shown { display: block; }

/* Preparing overlay */
.dz-overlay {
    position: fixed; inset: 0; z-index: 80; display: none;
    align-items: center; justify-content: center; flex-direction: column; gap: 18px;
    background: rgba(250, 247, 242, .86); backdrop-filter: blur(4px); color: var(--dz-ink);
}
.dz-overlay.is-open { display: flex; }
.dz-spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid rgba(184, 151, 102, .25); border-top-color: var(--dz-gold-deep); animation: dz-spin .8s linear infinite; }
@keyframes dz-spin { to { transform: rotate(360deg); } }
.dz-overlay p { font-family: var(--dz-serif); font-size: 1.2rem; color: var(--dz-ink); margin: 0; }

/* Mobile guard */
.dz-mobile-note { display: none; }
@media (max-width: 900px) {
    .dz-stage { display: none; }
    .dz-mobile-note {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        text-align: center; gap: 14px; position: fixed; inset: var(--dz-top) 0 0 0; padding: 40px 28px;
    }
    .dz-mobile-note .ic { width: 64px; height: 64px; color: var(--dz-gold-deep); }
    .dz-mobile-note h2 { font-family: var(--dz-serif); color: var(--dz-ink); font-size: 1.5rem; margin: 0; }
    .dz-mobile-note p { color: var(--dz-muted); max-width: 360px; line-height: 1.6; }
    .dz-hint { display: none; }
}
