
:root {
    --page-bg: #f4f6fb;
    --panel-bg: #ffffff;
    --ink: #151927;
    --muted: #6f7585;
    --border: #e3e7ef;
    --accent: #5362f5;
    --accent-dark: #111b36;
    --shadow: 0 22px 65px rgba(18, 27, 52, 0.18);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--page-bg);
    color: var(--ink);
    font-family: Inter, Arial, sans-serif;
    overflow: hidden;
}

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

button,
label[for],
input[type="file"] {
    cursor: pointer;
}

a {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px 0 28px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

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

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: var(--accent-dark);
}

.brand-mark svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: #fff;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 15px;
    line-height: 1.1;
}

.brand small {
    color: #798093;
    font-size: 11px;
    margin-top: 3px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.button {
    min-height: 38px;
    border: 0;
    border-radius: 9px;
    padding: 0 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-weight: 750;
    font-size: 13px;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: #111a35;
    color: #fff;
    box-shadow: 0 7px 18px rgba(17, 26, 53, .18);
}

.button-secondary {
    background: #eef1f7;
    color: #20283f;
}

.button-dark {
    background: #111a35;
    color: #fff;
}

.button-small {
    min-height: 30px;
    border-radius: 7px;
    padding: 0 11px;
    font-size: 11px;
}

.workspace {
    min-height: 0;
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 350px;
}

.preview-stage {
    min-width: 0;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 50% 46%, rgba(38, 50, 78, .12), transparent 30%),
        #f7f8fc;
}

.preview-toolbar {
    height: 54px;
    padding: 0 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(224, 228, 238, .9);
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(8px);
}

.preview-toolbar strong,
.preview-toolbar span {
    display: inline-block;
}

.preview-toolbar strong {
    font-size: 13px;
}

.preview-toolbar span {
    font-size: 11px;
    color: var(--muted);
    margin-left: 8px;
}

.preview-actions {
    display: flex;
    gap: 7px;
}

.icon-button {
    width: 31px;
    height: 31px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: #50596d;
}

.icon-button.is-active {
    color: #fff;
    border-color: #1d2949;
    background: #1d2949;
}

.preview-canvas {
    flex: 1;
    min-height: 0;
    padding: 42px;
    display: grid;
    place-items: center;
    overflow: auto;
}

.signature-frame {
    width: min(100%, 920px);
    transition: width .22s ease;
}

.signature-frame.is-mobile {
    width: min(100%, 420px);
}

.signature-preview {
    width: 100%;
    filter: drop-shadow(0 24px 35px rgba(20, 26, 48, .2));
}

.editor-panel {
    background: #fff;
    border-left: 1px solid var(--border);
    min-height: 0;
    overflow: hidden;
}

.panel-inner {
    height: 100%;
    overflow: auto;
    padding: 18px;
}

.editor-section {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid #edf0f5;
}

.editor-section-last {
    border-bottom: 0;
    padding-bottom: 4px;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.section-heading h2 {
    margin: 0;
    font-size: 13px;
    letter-spacing: -.01em;
}

.section-note {
    color: #9096a4;
    font-size: 9px;
}

.style-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.style-option {
    min-height: 61px;
    padding: 11px 10px;
    text-align: left;
    border: 1px solid #dfe4ec;
    border-radius: 10px;
    background: #fff;
    color: #1d2438;
    transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease;
}

.style-option:hover {
    transform: translateY(-1px);
    border-color: #aeb8cc;
}

.style-option strong,
.style-option span {
    display: block;
}

.style-option strong {
    font-size: 11px;
    margin-bottom: 5px;
}

.style-option span {
    color: #8991a3;
    font-size: 9px;
    line-height: 1.2;
}

.style-option.is-active {
    border-color: #111a35;
    background: #111a35;
    color: #fff;
}

.style-option.is-active span {
    color: #d7dded;
}

.image-upload-row {
    display: grid;
    gap: 14px;
}

.image-field > label {
    display: block;
    text-transform: uppercase;
    color: #697086;
    font-size: 9px;
    letter-spacing: .05em;
    font-weight: 800;
    margin-bottom: 8px;
}

.upload-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.image-thumbnail {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 1px dashed #cbd1dd;
    background: #f8f9fb;
    color: #b0b6c1;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
}

.image-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.text-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: #68718a;
    font-size: 10px;
}

.text-button:hover {
    color: #d74141;
}

.field-grid {
    display: grid;
    gap: 11px;
}

.field-grid.two-column {
    grid-template-columns: 1fr 1fr;
}

.field {
    display: grid;
    gap: 6px;
}

.field > span:first-child {
    text-transform: uppercase;
    color: #6e7588;
    font-size: 9px;
    letter-spacing: .04em;
    font-weight: 800;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid #dce1ea;
    border-radius: 8px;
    background: #fff;
    color: #20263a;
    outline: none;
    padding: 9px 10px;
    font-size: 11px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.field input,
.field select {
    height: 36px;
}

.field textarea {
    resize: vertical;
    min-height: 72px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: #7f8cff;
    box-shadow: 0 0 0 3px rgba(83, 98, 245, .12);
}

.colour-field {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 7px;
}

.colour-field input[type="color"] {
    padding: 4px;
}

.switch-list {
    margin-top: 15px;
    display: grid;
    gap: 10px;
}

.switch-row {
    min-height: 48px;
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
}

.switch-row > span:first-child {
    display: grid;
    gap: 3px;
}

.switch-row strong {
    font-size: 11px;
}

.switch-row small {
    color: #8a91a1;
    font-size: 9px;
}

.switch-row input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch {
    position: relative;
    width: 38px;
    height: 21px;
    border-radius: 999px;
    background: #d9deea;
    transition: background .18s ease;
}

.switch::after {
    content: "";
    position: absolute;
    width: 17px;
    height: 17px;
    top: 2px;
    left: 2px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(30, 38, 60, .22);
    transition: transform .18s ease;
}

.switch-row input:checked + .switch {
    background: #5362f5;
}

.switch-row input:checked + .switch::after {
    transform: translateX(17px);
}

.notice {
    padding: 13px;
    border-radius: 10px;
    background: #f3f5fb;
    color: #596175;
}

.notice strong {
    color: #293048;
    font-size: 11px;
}

.notice p {
    margin: 5px 0 0;
    font-size: 9px;
    line-height: 1.5;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 10;
    transform: translate(-50%, 15px);
    padding: 11px 16px;
    border-radius: 9px;
    background: #151c31;
    color: #fff;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
    box-shadow: 0 14px 35px rgba(12, 18, 36, .25);
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 980px) {
    body {
        overflow: auto;
    }

    .workspace {
        grid-template-columns: 1fr;
    }

    .preview-stage {
        min-height: 650px;
    }

    .editor-panel {
        border-left: 0;
        border-top: 1px solid var(--border);
        overflow: visible;
    }

    .panel-inner {
        height: auto;
        overflow: visible;
    }
}

@media (max-width: 620px) {
    .topbar {
        height: auto;
        padding: 14px;
        gap: 14px;
        align-items: flex-start;
    }

    .topbar-actions {
        flex-direction: column;
        width: 150px;
    }

    .topbar-actions .button {
        width: 100%;
    }

    .preview-canvas {
        padding: 22px 12px;
    }

    .preview-toolbar {
        padding: 0 12px;
    }

    .preview-toolbar span {
        display: none;
    }

    .field-grid.two-column {
        grid-template-columns: 1fr;
    }
}
