.xv-page-editor-root {
    position: relative;
    z-index: 9999;
    font-family: Inter, Arial, sans-serif;
}

.xv-page-editor-toggle {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 32px);
    padding: 10px 12px;
    color: #17202a;
    background: #ffffff;
    border: 1px solid #9fb2c8;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(10, 20, 30, 0.18);
}

.xv-page-editor-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
}

.xv-page-editor-toggle .xv-page-editor-toggle-label input[type="checkbox"] {
    position: static !important;
    width: 18px;
    height: 18px;
    opacity: 1 !important;
    pointer-events: auto !important;
}

.xv-page-editor-count {
    color: #4c627a;
    font-size: 12px;
    white-space: nowrap;
}

body.xv-page-editor-enabled [data-xv-editable-unit][data-xv-edit-type="html-fragment"] {
    position: relative;
    cursor: pointer;
    outline: 2px dashed #2878c7;
    outline-offset: -6px;
}

body.xv-page-editor-enabled [data-xv-editable-unit][data-xv-edit-type="html-fragment"]::before {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 5;
    max-width: calc(100% - 16px);
    padding: 5px 8px;
    content: "Edit " attr(data-xv-edit-label);
    color: #ffffff;
    background: #2878c7;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    pointer-events: none;
}

body.xv-page-editor-enabled .xv-page-editor-active-unit {
    outline-color: #ce3f32;
    outline-style: solid;
}

body.xv-page-editor-enabled .xv-page-editor-dirty-unit {
    outline-color: #d68910;
}

.xv-page-editor-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(560px, 100vw);
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    overflow: auto;
    color: #17202a;
    background: #ffffff;
    border-left: 1px solid #9fb2c8;
    box-shadow: -12px 0 30px rgba(10, 20, 30, 0.22);
}

.xv-page-editor-panel[hidden],
.xv-page-editor-root[hidden],
.xv-page-editor-source[hidden] {
    display: none;
}

.xv-page-editor-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.xv-page-editor-kicker {
    margin: 0 0 2px;
    color: #4c627a;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.xv-page-editor-panel h2 {
    margin: 0;
    color: #17202a;
    font-size: 24px;
    line-height: 1.2;
}

.xv-page-editor-unit-id {
    margin: 4px 0 0;
    color: #4c627a;
    font-family: Consolas, monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.xv-page-editor-icon-button,
.xv-page-editor-primary-button,
.xv-page-editor-secondary-button {
    min-height: 36px;
    border-radius: 6px;
    border: 1px solid #9fb2c8;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}

.xv-page-editor-icon-button {
    width: 36px;
    background: #ffffff;
}

.xv-page-editor-primary-button {
    color: #ffffff;
    background: #1f6fb5;
    border-color: #1f6fb5;
    padding: 0 16px;
}

.xv-page-editor-secondary-button {
    color: #17202a;
    background: #f4f7fa;
    padding: 0 14px;
}

.xv-page-editor-primary-button:disabled,
.xv-page-editor-secondary-button:disabled {
    cursor: wait;
    opacity: 0.6;
}

.xv-page-editor-message {
    min-height: 20px;
    padding: 8px 10px;
    color: #33485f;
    background: #eef5fb;
    border-radius: 6px;
    font-size: 13px;
}

.xv-page-editor-message.is-error {
    color: #7a211a;
    background: #fdeceb;
}

.xv-page-editor-message.is-success {
    color: #165a34;
    background: #e7f6ec;
}

.xv-page-editor-tools {
    display: flex;
    align-items: stretch;
    gap: 8px;
    flex-wrap: wrap;
}

.xv-page-editor-file-label {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    color: #17202a;
    background: #f4f7fa;
    border: 1px solid #9fb2c8;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
}

.xv-page-editor-file-label input {
    display: none;
}

.xv-page-editor-host,
.xv-page-editor-source {
    min-height: 360px;
    width: 100%;
    border: 1px solid #9fb2c8;
    border-radius: 8px;
    background: #ffffff;
}

.xv-page-editor-source {
    padding: 12px;
    resize: vertical;
    color: #17202a;
    font-family: Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
}

.xv-page-editor-host textarea {
    min-height: 360px;
    width: 100%;
    padding: 12px;
    border: 0;
    outline: 0;
    resize: vertical;
    font-family: Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
}

.xv-page-editor-host .ck-editor__editable_inline {
    min-height: 320px;
}

.xv-page-editor-preview-note {
    margin: 0;
    color: #4c627a;
    font-size: 13px;
}

.xv-page-editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding-bottom: 12px;
}

@media (max-width: 700px) {
    .xv-page-editor-toggle {
        right: 10px;
        bottom: 10px;
    }

    .xv-page-editor-panel {
        width: 100vw;
        padding: 12px;
    }
}
