.profile-media-editor[hidden] { display: none !important; }
.profile-media-editor {
    position: fixed;
    z-index: 11050;
    inset: 0;
    display: grid;
    padding: 24px;
    color: #fff;
    place-items: center;
}
.profile-media-editor__backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(0, 0, 0, .82);
    backdrop-filter: blur(8px);
}
.profile-media-editor__dialog {
    position: relative;
    z-index: 1;
    width: min(580px, 100%);
    max-height: min(820px, calc(100svh - 48px));
    overflow: auto;
    border: 1px solid #2b2b31;
    border-radius: 8px;
    background: #111115;
    box-shadow: 0 24px 72px rgba(0, 0, 0, .64);
}
.profile-media-editor__header,
.profile-media-editor__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px;
}
.profile-media-editor__header { border-bottom: 1px solid #26262b; }
.profile-media-editor__header span { display: block; margin-bottom: 4px; color: var(--theme-color); font-size: 10px; font-weight: 800; }
.profile-media-editor__header h2 { margin: 0; color: #fff; font-size: 19px; line-height: 1.2; }
.profile-media-editor__close {
    display: grid;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    color: #a9a9b2;
    background: transparent;
    place-items: center;
}
.profile-media-editor__close:hover { color: #fff; background: #202025; }
.profile-media-editor__close .icon { width: 17px; height: 17px; fill: currentColor; }
.profile-media-editor__sources {
    display: grid;
    padding: 18px 22px 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.profile-media-editor__source {
    display: flex;
    min-height: 44px;
    border: 1px solid #2c2c32;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    gap: 9px;
    color: #b6b6bf;
    background: #17171b;
    font-weight: 700;
}
.profile-media-editor__source:hover,
.profile-media-editor__source.is-active { border-color: var(--theme-color); color: #fff; }
.profile-media-editor__source .icon { width: 18px; height: 18px; fill: currentColor; }
.profile-media-editor__workspace,
.profile-media-editor__library { padding: 18px 22px 22px; }
.profile-media-editor__canvas-wrap {
    display: grid;
    width: 100%;
    max-height: 440px;
    overflow: hidden;
    border: 1px solid #303036;
    border-radius: 6px;
    background: #08080a;
    place-items: center;
    touch-action: none;
    cursor: grab;
}
.profile-media-editor__canvas-wrap.is-dragging { cursor: grabbing; }
.profile-media-editor__canvas-wrap canvas { display: block; width: 100%; height: auto; max-height: 440px; object-fit: contain; }
.profile-media-editor__zoom {
    display: grid;
    margin-top: 18px;
    align-items: center;
    grid-template-columns: 22px minmax(0, 1fr) 22px;
    gap: 10px;
    color: #8f8f98;
}
.profile-media-editor__zoom input { width: 100%; accent-color: var(--theme-color); }
.profile-media-editor__hint { margin: 8px 0 0; color: #83838c; font-size: 12px; text-align: center; }
.profile-media-editor__library { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.profile-media-editor__library[hidden] { display: none !important; }
.profile-media-editor__library-item {
    position: relative;
    overflow: hidden;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    aspect-ratio: 1;
    background: #202025;
}
.profile-media-editor__library-item:hover,
.profile-media-editor__library-item:focus { border-color: var(--theme-color); }
.profile-media-editor__library-item img { width: 100%; height: 100%; object-fit: cover; }
.profile-media-editor__empty { grid-column: 1 / -1; margin: 30px 0; color: #8f8f98; text-align: center; }
.profile-media-editor__footer { border-top: 1px solid #26262b; justify-content: flex-end; }
.profile-media-editor__footer .btn { min-width: 120px; min-height: 42px; border-radius: 6px; }
.profile-media-editor__cancel { color: #d7d7dd; background: #202025; }
.profile-media-editor__cancel:hover { color: #fff; background: #29292f; }
body.profile-media-editor-open { overflow: hidden !important; }

@media (max-width: 575.98px) {
    .profile-media-editor { padding: 0; align-items: end; }
    .profile-media-editor__dialog {
        width: 100%;
        max-height: 90svh;
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 8px 8px 0 0;
    }
    .profile-media-editor__header,
    .profile-media-editor__footer { padding: 16px; }
    .profile-media-editor__sources { padding: 14px 16px 0; }
    .profile-media-editor__workspace,
    .profile-media-editor__library { padding: 14px 16px 18px; }
    .profile-media-editor__library { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .profile-media-editor__footer .btn { flex: 1 1 0; min-width: 0; }
}
