:root {
    --ink: #181614;
    --muted: #6f6a63;
    --paper: #fbfaf6;
    --panel: #ffffff;
    --line: #ded8cf;
    --soft-line: #eee9e1;
    --accent: #ff0055;
    --accent-dark: #c70043;
    --focus: rgba(255, 0, 85, .18);
    --shadow: 0 18px 55px rgba(32, 26, 20, .11);
    --font-body: "DM Sans", "Helvetica Neue", Arial, sans-serif;
    --font-display: "DM Serif Display", Georgia, serif;
}

* {
    box-sizing: border-box;
}

html {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    min-height: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    max-width: 100%;
    overflow-x: hidden;
}

a {
    color: inherit;
}

button,
input,
select,
textarea {
    font: inherit;
    min-width: 0;
}

.brand-mark {
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 28px;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
}

.brand-mark em {
    color: var(--accent);
    font-style: normal;
}

.gate-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 28px;
}

.gate-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 520px;
    padding: 34px;
}

.gate-panel h1 {
    font-family: var(--font-display);
    font-size: clamp(44px, 8vw, 72px);
    line-height: .92;
    margin: 28px 0 14px;
}

.gate-panel p:last-child {
    color: var(--muted);
    font-size: 18px;
    line-height: 1.55;
    margin: 0;
}

.editor-page {
    background:
        linear-gradient(90deg, rgba(24, 22, 20, .04) 1px, transparent 1px),
        linear-gradient(180deg, rgba(24, 22, 20, .04) 1px, transparent 1px),
        var(--paper);
    background-size: 36px 36px;
}

.app-topbar {
    align-items: center;
    background: rgba(251, 250, 246, .92);
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 18px;
    justify-content: space-between;
    min-height: 68px;
    padding: 14px 22px;
    position: sticky;
    top: 0;
    z-index: 20;
}

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

.ghost-button,
.primary-button {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    font-weight: 700;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    text-decoration: none;
    min-width: 0;
}

.ghost-button {
    background: #ffffff;
    border: 1px solid var(--line);
    color: var(--ink);
}

.primary-button {
    background: var(--accent);
    border: 1px solid var(--accent);
    color: #ffffff;
    cursor: pointer;
}

.primary-button:hover,
.primary-button:focus {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.editor-workspace {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
    height: calc(100vh - 68px);
    max-width: 100vw;
    overflow-x: hidden;
    padding: 18px;
    width: 100%;
}

.control-panel,
.preview-panel {
    background: rgba(255, 255, 255, .96);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    width: 100%;
}

.control-panel {
    overflow-y: auto;
    padding: 24px;
}

.panel-heading {
    border-bottom: 1px solid var(--soft-line);
    margin: 0 0 22px;
    padding: 0 0 18px;
}

.panel-kicker {
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.panel-heading h1 {
    font-family: var(--font-display);
    font-size: 48px;
    line-height: .94;
    margin: 0;
    overflow-wrap: anywhere;
}

.save-state {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    margin: 10px 0 0;
}

.alert-block,
.success-block {
    border-radius: 8px;
    font-weight: 700;
    line-height: 1.45;
    margin: 0 0 18px;
    padding: 12px 14px;
}

.alert-block {
    background: #fff3f5;
    border: 1px solid #f2b4c3;
    color: #861233;
}

.alert-block p {
    margin: 0;
}

.success-block {
    background: #eff9f1;
    border: 1px solid #b8dfbe;
    color: #24612e;
}

.editor-form {
    display: grid;
    gap: 18px;
}

fieldset {
    border: 0;
    border-top: 1px solid var(--soft-line);
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 18px 0 0;
}

legend {
    color: var(--ink);
    font-size: 15px;
    font-weight: 800;
    padding: 0 12px 0 0;
}

.input-label {
    color: var(--muted);
    display: block;
    font-size: 13px;
    font-weight: 800;
    margin: 3px 0 6px;
}

input,
select,
textarea {
    background: #fffefa;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    min-height: 42px;
    outline: none;
    padding: 10px 12px;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
    width: 100%;
    max-width: 100%;
}

input[type="file"] {
    display: none;
}

textarea {
    line-height: 1.45;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    background: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus);
}

.field-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr 1fr;
}

.color-row {
    align-items: center;
    display: grid;
    gap: 8px;
    grid-template-columns: 44px 1fr;
}

.color-row input[type="color"] {
    cursor: pointer;
    height: 42px;
    padding: 4px;
}

.check-row {
    align-items: center;
    color: var(--ink);
    display: flex;
    font-size: 14px;
    font-weight: 700;
    gap: 10px;
}

.check-row input {
    accent-color: var(--accent);
    min-height: auto;
    width: auto;
}

.upload-dropzone {
    align-items: center;
    background: #fffefa;
    border: 1px dashed #cfc7bd;
    border-radius: 8px;
    cursor: pointer;
    display: grid;
    gap: 12px;
    grid-template-columns: 74px 1fr;
    margin: 2px 0 4px;
    padding: 12px;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.upload-dropzone:hover,
.upload-dropzone.is-dragover {
    background: #ffffff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus);
}

.upload-preview {
    align-items: center;
    aspect-ratio: 1;
    background: #f1ede6;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    overflow: hidden;
}

.upload-preview img {
    display: block;
    height: 100%;
    object-fit: contain;
    width: 100%;
}

.upload-dropzone label {
    color: var(--ink);
    cursor: pointer;
    display: block;
    font-weight: 800;
    margin: 0 0 4px;
}

.upload-dropzone p {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
    margin: 0;
}

.preview-panel {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.preview-toolbar {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    min-height: 72px;
    padding: 14px 16px;
}

.preview-toolbar strong {
    display: block;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viewport-switch {
    background: #f2eee7;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    padding: 3px;
}

.viewport-switch button {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    font-weight: 800;
    min-height: 34px;
    padding: 0 12px;
}

.viewport-switch button.is-active {
    background: #ffffff;
    color: var(--ink);
    box-shadow: 0 1px 5px rgba(24, 22, 20, .1);
}

.preview-stage {
    align-items: stretch;
    background: #f1ece4;
    display: flex;
    justify-content: center;
    min-height: 0;
    padding: 18px;
}

.preview-stage iframe {
    background: #ffffff;
    border: 1px solid #d6cec3;
    border-radius: 8px;
    box-shadow: 0 16px 38px rgba(42, 35, 28, .14);
    height: 100%;
    max-width: 100%;
    width: 100%;
}

.preview-stage.is-mobile iframe {
    max-width: 390px;
}

@media (max-width: 980px) {
    .editor-workspace {
        grid-template-columns: 1fr;
        height: auto;
    }

    .preview-panel {
        min-height: 720px;
    }
}

@media (max-width: 620px) {
    .app-topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        margin: 0 auto;
        max-width: 340px;
        position: static;
        width: 100%;
    }

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

    .ghost-button,
    .primary-button {
        flex: 1;
        padding-left: 10px;
        padding-right: 10px;
    }

    .editor-workspace {
        margin: 0 auto;
        max-width: 340px;
        padding: 10px;
    }

    .control-panel {
        padding: 18px;
    }

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

    .upload-dropzone {
        grid-template-columns: 58px 1fr;
    }

    .preview-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }
}
