body.agency-editor-open {
    overflow: hidden;
}

#agency-edit-button {
    position: fixed;
    top: 70px;
    right: 18px;
    z-index: 10000;
}

#agency-editor-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    padding: 24px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.82);
    align-items: center;
    justify-content: center;
    z-index: 100000;
}

#agency-editor-popup {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(1000px, 86vw);
    height: min(760px, 88vh);
    padding: 22px;
    box-sizing: border-box;
    overflow: hidden;
    background: #fff;
    color: #222;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
    font-family: 'Montserrat', sans-serif;
}

#agency-editor-close {
    position: absolute;
    top: 10px;
    right: 15px;
    z-index: 2;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: #222;
    box-shadow: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.agency-editor-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding-right: 34px;
    margin-bottom: 18px;
}

.agency-editor-tab {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #c2c2c2;
    box-shadow: none;
    font: inherit;
    cursor: pointer;
}

.agency-editor-tab:hover,
.agency-editor-tab.active {
    background: transparent;
    color: dimgrey;
}

.agency-editor-panel {
    display: none;
    min-height: 0;
    flex: 1;
    flex-direction: column;
}

.agency-editor-panel.active {
    display: flex;
}

.agency-current-image {
    flex: 1 1 52%;
    min-height: 180px;
    overflow: hidden;
    background: #f4f4f4;
}

.agency-current-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.agency-upload-button {
    align-self: flex-start;
    margin: 12px 0;
    padding: 8px 11px;
    border: 1px solid #dedede;
    border-radius: 4px;
    background: #fff;
    color: #777;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.agency-upload-button:hover,
.agency-upload-button:focus {
    background: #eee;
    color: #333;
    outline: none;
}

.agency-upload-button.disabled {
    cursor: wait;
    opacity: 0.55;
}

#agency-image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
    gap: 10px;
    max-height: 180px;
    overflow-y: auto;
    padding: 2px;
}

.agency-gallery-item {
    position: relative;
    aspect-ratio: 16 / 9;
    border: 2px solid transparent;
    box-sizing: border-box;
    overflow: hidden;
    background: #eee;
}

.agency-gallery-item.active {
    border-color: #777;
}

.agency-gallery-select {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    cursor: pointer;
}

.agency-gallery-select:disabled {
    cursor: default;
}

.agency-gallery-select img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: none;
}

.agency-gallery-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    display: grid;
    width: 25px;
    height: 25px;
    margin: 0;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    box-shadow: none;
    font-size: 13px;
    cursor: pointer;
}

.agency-gallery-delete:hover {
    background: #8f2525;
}

.agency-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.agency-editor-toolbar button {
    min-width: 34px;
    margin: 0;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fafafa;
    color: #333;
    box-shadow: none;
    font: inherit;
    font-size: 0.84rem;
    cursor: pointer;
}

.agency-editor-toolbar button:hover {
    background: #eee;
}

.agency-rich-editor {
    flex: 1;
    min-height: 0;
    padding: 15px;
    overflow-y: auto;
    border: 1px solid #ccc;
    background: #fff;
    color: #222;
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.5;
    outline: none;
}

.agency-rich-editor:focus {
    border-color: #888;
}

.agency-rich-editor ul,
.agency-rich-editor ol {
    padding-left: 24px;
}

.agency-rich-editor li::before,
#agency-editor-popup li::before {
    content: none;
}

.agency-editor-status {
    min-height: 1.2em;
    padding-top: 7px;
    color: #888;
    font-size: 0.82rem;
}

.agency-editor-status.error {
    color: #b44;
}

.skills-editor-popup .agency-editor-panel {
    overflow-y: auto;
    padding-right: 8px;
}

.skills-editor-fields {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.skills-editor-field-group {
    padding-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.skills-editor-field-group:last-child {
    border-bottom: 0;
}

.skills-editor-field-group > h3 {
    margin: 0 0 10px;
    font-size: 1rem;
}

.skills-title-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
    color: #777;
    font-size: 0.8rem;
}

.skills-title-input {
    width: 100%;
    padding: 8px 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    background: #fff;
    color: #222;
    font: inherit;
}

.skills-title-input:focus {
    border-color: #888;
    outline: none;
}

.skills-rich-editor {
    flex: 0 0 auto;
    min-height: 150px;
    max-height: 300px;
}

.skills-rich-editor .text-column {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 14px;
}

.skills-rich-editor .text {
    text-align: center;
}

@media (max-width: 700px) {
    #agency-edit-button {
        top: 58px;
        right: 10px;
    }

    #agency-editor-overlay {
        padding: 8px;
    }

    #agency-editor-popup {
        width: 100%;
        height: 94vh;
        padding: 16px;
    }

    .agency-editor-tabs {
        gap: 12px;
        padding-right: 30px;
    }

    .agency-editor-tab {
        font-size: 0.84rem;
    }

    .agency-current-image {
        min-height: 150px;
    }

    #agency-image-gallery {
        grid-template-columns: repeat(2, 1fr);
        max-height: 220px;
    }

    .agency-editor-toolbar button {
        padding: 5px 7px;
        font-size: 0.76rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .agency-upload-button {
        transition: none;
    }
}
