.custom-select {
    position: relative;
    width: 100%;
    min-width: 0;
}

.custom-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-width: 1px !important;
    min-height: 1px !important;
    margin: 0 !important;
    padding: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
}

.custom-select-trigger {
    position: relative;
    width: 100%;
    min-width: 0;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 38px 9px 11px;
    border: 1px solid var(--control-line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    line-height: 1.45;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.custom-select-trigger:hover {
    border-color: var(--focus);
}

.custom-select.is-open .custom-select-trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-shadow);
}

.custom-select-trigger:disabled {
    cursor: default;
    opacity: .6;
}

.custom-select-value {
    display: block;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.custom-select-chevron {
    position: absolute;
    right: 14px;
    top: 50%;
    width: 8px;
    height: 8px;
    margin-top: -6px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform .16s ease, margin .16s ease, border-color .16s ease;
    pointer-events: none;
}

.custom-select.is-open .custom-select-chevron {
    margin-top: -2px;
    transform: rotate(225deg);
    border-color: var(--accent-dark);
}

.custom-select-menu {
    position: absolute;
    z-index: 120;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    max-height: 280px;
    padding: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: 0 18px 44px rgba(12, 24, 38, .18);
    scrollbar-width: thin;
}

.custom-select.opens-up .custom-select-menu {
    top: auto;
    bottom: calc(100% + 8px);
}

.custom-select-option {
    width: 100%;
    min-width: 0;
    min-height: 40px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    line-height: 1.35;
    text-align: left;
    overflow-wrap: anywhere;
    cursor: pointer;
    transition: background .12s ease, color .12s ease;
}

.custom-select-option:hover,
.custom-select-option.is-active {
    background: var(--surface-alt);
}

.custom-select-option.is-selected,
.custom-select-option.is-selected:hover,
.custom-select-option.is-selected.is-active {
    background: var(--accent-soft);
    color: var(--accent-dark);
    font-weight: 700;
}

.custom-select-option.is-selected::after {
    content: "✓";
    color: var(--accent);
    font-size: 13px;
    font-weight: 800;
}

.custom-select-option:disabled {
    color: var(--muted);
    cursor: default;
    opacity: .55;
}

.custom-select-option:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: -2px;
}

/* В карточке поля уже имеют собственную рамку и фон — меню становится частью поля, а не вторым вложенным контролом. */
.card-form .field .custom-select-trigger,
.assigned-user-editor .custom-select-trigger,
.comment-entry-field .custom-select-trigger {
    min-height: 26px;
    padding: 2px 30px 0 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.card-form .field .custom-select-trigger:hover,
.assigned-user-editor .custom-select-trigger:hover,
.comment-entry-field .custom-select-trigger:hover,
.card-form .field .custom-select.is-open .custom-select-trigger,
.assigned-user-editor .custom-select.is-open .custom-select-trigger,
.comment-entry-field .custom-select.is-open .custom-select-trigger {
    border: 0;
    background: transparent;
    box-shadow: none;
}

.card-form .field .custom-select-trigger:focus-visible,
.assigned-user-editor .custom-select-trigger:focus-visible,
.comment-entry-field .custom-select-trigger:focus-visible {
    outline: 0;
}

.card-form .field .custom-select-chevron,
.assigned-user-editor .custom-select-chevron,
.comment-entry-field .custom-select-chevron {
    right: 5px;
}

.assigned-user-editor .custom-select-trigger {
    font-weight: 700;
}

@media (max-width: 620px) {
    .custom-select-menu {
        max-height: min(280px, 45vh);
    }

    .custom-select-trigger,
    .custom-select-option {
        font-size: 16px;
    }

    .card-form .field .custom-select-trigger,
    .assigned-user-editor .custom-select-trigger,
    .comment-entry-field .custom-select-trigger {
        font-size: 16px;
    }
}
